| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
3201
|
use Moops -strict; |
|
|
2
|
|
|
|
|
102250
|
|
|
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: interfaces with Intercom.io |
|
4
|
|
|
|
|
|
|
# PODNAME: WebService::Intercom |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=pod |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
WebService::Intercom - interact with the Intercom.io API |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $intercom = WebService::Intercom->new(app_id => '[APP ID]', |
|
15
|
|
|
|
|
|
|
api_key => '[API KEY]'); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Create a user |
|
18
|
|
|
|
|
|
|
my $user = $intercom->user_create_or_update( |
|
19
|
|
|
|
|
|
|
email => 'test@example.com', |
|
20
|
|
|
|
|
|
|
name => 'test user'); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Retrieve an existing user. |
|
23
|
|
|
|
|
|
|
my $existing_user = $intercom->user_get(email => 'test2@example.com'); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Add a tag to a user |
|
26
|
|
|
|
|
|
|
$user->tag('test tag'); |
|
27
|
|
|
|
|
|
|
$intercom->tag_create_or_update(name => "test tag"); |
|
28
|
|
|
|
|
|
|
$intercom->tag_items(name => "test tag", users => [{ email => 'test@example.com'}]); |
|
29
|
|
|
|
|
|
|
$user->untag('test tag'); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Change the user's name |
|
32
|
|
|
|
|
|
|
$user->name = 'new name'; |
|
33
|
|
|
|
|
|
|
$user->save(); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Delete the user |
|
36
|
|
|
|
|
|
|
$user->delete(); |
|
37
|
|
|
|
|
|
|
$intercom->user_delete(email => 'test@example.com'); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Add a note |
|
40
|
|
|
|
|
|
|
$user->add_note(body => "This is a test note"); |
|
41
|
|
|
|
|
|
|
$intercom->note_create(email => 'test@example.com', |
|
42
|
|
|
|
|
|
|
body => "This is a test note"); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Add an event |
|
45
|
|
|
|
|
|
|
$user->add_event(event_name => 'test event'); |
|
46
|
|
|
|
|
|
|
$intercom->event_create(email => 'test@example.com', |
|
47
|
|
|
|
|
|
|
event_name => 'test event', |
|
48
|
|
|
|
|
|
|
metadata => { |
|
49
|
|
|
|
|
|
|
"article" => {"url" => "https://example.org/", |
|
50
|
|
|
|
|
|
|
"value" => "link text"}, |
|
51
|
|
|
|
|
|
|
}); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Provides a nice API for Intercom.io rather than making raw requests. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 IMPLEMENTATION PHILOSOPHY |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This module attempts to stick as close to the API as possible. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Documentation for the v2 API: |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
L<http://doc.intercom.io/api/> |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
For examples see the test cases, most functionality is well exercised |
|
66
|
|
|
|
|
|
|
via tests. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
2
|
|
|
2
|
|
116471
|
use WebService::Intercom::Exception; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
77
|
|
|
72
|
2
|
|
|
2
|
|
782
|
use WebService::Intercom::Types; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
33
|
|
|
73
|
2
|
|
|
2
|
|
2815
|
use WebService::Intercom::User; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
143
|
|
|
74
|
2
|
|
|
2
|
|
1080
|
use WebService::Intercom::Tag; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
127
|
|
|
75
|
2
|
|
|
2
|
|
950
|
use WebService::Intercom::Note; |
|
|
2
|
|
|
|
|
135
|
|
|
|
2
|
|
|
|
|
120
|
|
|
76
|
2
|
|
|
2
|
|
966
|
use WebService::Intercom::Message; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
95
|
|
|
77
|
2
|
|
|
2
|
|
833
|
use WebService::Intercom::Admin; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
164
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
2
|
|
|
2
|
|
3135
|
class WebService::Intercom types WebService::Intercom::Types { |
|
|
2
|
|
|
2
|
|
53
|
|
|
|
2
|
|
|
2
|
|
14
|
|
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
116
|
|
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
16
|
|
|
|
2
|
|
|
|
|
540
|
|
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
12
|
|
|
|
2
|
|
|
|
|
107
|
|
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
156
|
|
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
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::Request::Common qw(DELETE POST GET); |
|
|
2
|
|
|
|
|
4424
|
|
|
|
2
|
|
|
|
|
177
|
|
|
83
|
2
|
|
|
2
|
|
1277
|
use JSON::XS; |
|
|
2
|
|
|
|
|
10588
|
|
|
|
2
|
|
|
|
|
146
|
|
|
84
|
2
|
|
|
2
|
|
921
|
use MIME::Base64; |
|
|
2
|
|
|
|
|
1259
|
|
|
|
2
|
|
|
|
|
141
|
|
|
85
|
2
|
|
|
2
|
|
10
|
use Kavorka qw( multi method ); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
24
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
2
|
|
|
|
|
33
|
has 'ua' => (is => 'ro', default => sub { return LWP::UserAgent->new(keep_alive => 10, agent => "WebService::Intercom/1.0") } ); |
|
|
0
|
|
|
|
|
0
|
|
|
89
|
2
|
|
|
|
|
1360
|
has 'app_id' => (is => 'ro'); |
|
90
|
2
|
|
|
|
|
488
|
has 'api_key' => (is => 'ro'); |
|
91
|
|
|
|
|
|
|
|
|
92
|
2
|
|
|
|
|
474
|
has 'api_base' => (is => 'ro', isa => Str, default => 'https://api.intercom.io'); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 user_get |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Retrieves an existing user. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$intercom->user_get(Maybe[Str] :$user_id?, |
|
101
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
|
102
|
|
|
|
|
|
|
Maybe[Str] :$id?); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Only one of user_id, email or id are required to retrieve a user. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns a L<WebService::Intercom::User>. |
|
107
|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!(defined($user_id) xor defined($email) xor defined($id))) { |
|
|
|
|
0
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "One and only one of user_id, email or id must be defined"}); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
my $request; |
|
120
|
0
|
0
|
|
|
|
|
if (defined($id)) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
$request = GET($self->api_base . '/users/' . $id); |
|
122
|
|
|
|
|
|
|
} elsif (defined($user_id)) { |
|
123
|
0
|
|
|
|
|
|
$request = GET($self->api_base . '/users?user_id=' . URI::Escape::uri_escape($user_id)); |
|
124
|
|
|
|
|
|
|
} elsif (defined($email)) { |
|
125
|
0
|
|
|
|
|
|
$request = GET($self->api_base . '/users?email=' . URI::Escape::uri_escape($email)); |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
$self->_request($request); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 user_create_or_update |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Creates or updates a user. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
|
136
|
|
|
|
|
|
|
$intercom->user_create_or_update(WebService::Intercom::User $user); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
or |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
$intercom->user_create_or_update(Maybe[Str] :$user_id?, |
|
141
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
|
142
|
|
|
|
|
|
|
Maybe[Str] :$id?, |
|
143
|
|
|
|
|
|
|
Maybe[Int] :$signed_up_at?, |
|
144
|
|
|
|
|
|
|
Str :$name?, |
|
145
|
|
|
|
|
|
|
Maybe[IPAddressType] :$last_seen_ip?, |
|
146
|
|
|
|
|
|
|
CustomAttributesType :$custom_attributes?, |
|
147
|
|
|
|
|
|
|
Maybe[Str] :$last_seen_user_agent?, |
|
148
|
|
|
|
|
|
|
HashRef :$companies?, |
|
149
|
|
|
|
|
|
|
Maybe[Int] :$last_request_at?, |
|
150
|
|
|
|
|
|
|
Maybe[Bool] :$unsubscribed_from_emails?, |
|
151
|
|
|
|
|
|
|
Maybe[Bool] :$update_last_request_at?, |
|
152
|
|
|
|
|
|
|
Maybe[Bool] :$new_session?); |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Returns a L<WebService::Intercom::User> that represents the new or updated user. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
|
160
|
2
|
0
|
|
2
|
|
5636
|
multi method user_create_or_update(WebService::Intercom::User $user) { |
|
|
2
|
0
|
|
2
|
|
4
|
|
|
|
2
|
0
|
|
0
|
|
481
|
|
|
|
2
|
0
|
|
|
|
12
|
|
|
|
2
|
0
|
|
|
|
3
|
|
|
|
2
|
0
|
|
|
|
256
|
|
|
|
2
|
0
|
|
|
|
441
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
return $self->user_create_or_update(user_id => $user->user_id, |
|
162
|
|
|
|
|
|
|
email => $user->email, |
|
163
|
|
|
|
|
|
|
id => $user->id, |
|
164
|
|
|
|
|
|
|
name => $user->name, |
|
165
|
|
|
|
|
|
|
last_seen_ip => $user->last_seen_ip, |
|
166
|
|
|
|
|
|
|
custom_attributes => $user->custom_attributes, |
|
167
|
|
|
|
|
|
|
last_seen_user_agent => $user->user_agent_data, |
|
168
|
|
|
|
|
|
|
last_request_at => $user->last_request_at, |
|
169
|
|
|
|
|
|
|
unsubscribed_from_emails => $user->unsubscribed_from_emails, |
|
170
|
|
|
|
|
|
|
); |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
multi method user_create_or_update(Maybe[Str] :$user_id?, |
|
174
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
|
175
|
|
|
|
|
|
|
Maybe[Str] :$id?, |
|
176
|
|
|
|
|
|
|
Maybe[Int] :$signed_up_at?, |
|
177
|
|
|
|
|
|
|
Str :$name?, |
|
178
|
|
|
|
|
|
|
Maybe[IPAddressType] :$last_seen_ip?, |
|
179
|
|
|
|
|
|
|
CustomAttributesType :$custom_attributes?, |
|
180
|
|
|
|
|
|
|
Maybe[Str] :$last_seen_user_agent?, |
|
181
|
|
|
|
|
|
|
HashRef :$companies?, |
|
182
|
|
|
|
|
|
|
Maybe[Int] :$last_request_at?, |
|
183
|
|
|
|
|
|
|
Maybe[Bool] :$unsubscribed_from_emails?, |
|
184
|
|
|
|
|
|
|
Maybe[Bool] :$update_last_request_at?, |
|
185
|
2
|
0
|
0
|
2
|
|
39440
|
Maybe[Bool] :$new_session?) { |
|
|
2
|
0
|
0
|
2
|
|
5
|
|
|
|
2
|
0
|
|
2
|
|
354
|
|
|
|
2
|
0
|
|
2
|
|
10
|
|
|
|
2
|
0
|
|
2
|
|
4
|
|
|
|
2
|
0
|
|
2
|
|
537
|
|
|
|
2
|
0
|
|
2
|
|
11
|
|
|
|
2
|
0
|
|
2
|
|
3
|
|
|
|
2
|
0
|
|
2
|
|
315
|
|
|
|
2
|
0
|
|
2
|
|
14
|
|
|
|
2
|
0
|
|
2
|
|
3
|
|
|
|
2
|
0
|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
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
my $json_content = { |
|
189
|
|
|
|
|
|
|
signed_up_at => $signed_up_at, |
|
190
|
|
|
|
|
|
|
name => $name, |
|
191
|
|
|
|
|
|
|
last_seen_ip => $last_seen_ip, |
|
192
|
|
|
|
|
|
|
custom_attributes => $custom_attributes, |
|
193
|
|
|
|
|
|
|
last_seen_user_agent => $last_seen_user_agent, |
|
194
|
|
|
|
|
|
|
companies => $companies, |
|
195
|
|
|
|
|
|
|
last_request_at => $last_request_at, |
|
196
|
|
|
|
|
|
|
unsubscribed_from_emails => $unsubscribed_from_emails, |
|
197
|
|
|
|
|
|
|
update_last_request_at => $update_last_request_at, |
|
198
|
|
|
|
|
|
|
new_session => $new_session |
|
199
|
|
|
|
|
|
|
}; |
|
200
|
|
|
|
|
|
|
|
|
201
|
0
|
0
|
|
|
|
|
if (defined($user_id)) { |
|
202
|
0
|
|
|
|
|
|
$json_content->{user_id} = $user_id; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
0
|
0
|
|
|
|
|
if (defined($email)) { |
|
205
|
0
|
|
|
|
|
|
$json_content->{email} = $email; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
0
|
0
|
|
|
|
|
if (defined($id)) { |
|
208
|
0
|
|
|
|
|
|
$json_content->{id} = $id; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
|
|
211
|
0
|
|
|
|
|
|
my $json = JSON::XS::encode_json($json_content); |
|
212
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/users', |
|
213
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
|
214
|
|
|
|
|
|
|
Content => $json |
|
215
|
|
|
|
|
|
|
); |
|
216
|
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
$self->_request($request); |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head2 user_delete |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Deletes a user |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
|
226
|
|
|
|
|
|
|
$intercom->user_delete(WebService::Intercom::User $user); |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
or |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
$intercom->user_delete(Maybe[Str] :$user_id?, |
|
231
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
|
232
|
|
|
|
|
|
|
Maybe[Str] :$id?); |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Only one of user_id, email or id is required. |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Returns a L<WebService::Intercom::User> that represents the deleted user. |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=cut |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
|
|
241
|
2
|
0
|
|
2
|
|
5468
|
multi method user_delete(WebService::Intercom::User $user) { |
|
|
2
|
0
|
|
2
|
|
4
|
|
|
|
2
|
0
|
|
0
|
|
392
|
|
|
|
2
|
0
|
|
|
|
8
|
|
|
|
2
|
0
|
|
|
|
5
|
|
|
|
2
|
0
|
|
|
|
192
|
|
|
|
2
|
0
|
|
|
|
343
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
return $self->user_delete(user_id => $user->user_id, |
|
243
|
|
|
|
|
|
|
id => $user->id, |
|
244
|
|
|
|
|
|
|
email => $user->email); |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
multi method user_delete(Str :$user_id?, |
|
248
|
|
|
|
|
|
|
Str :$id?, |
|
249
|
2
|
0
|
0
|
2
|
|
8891
|
Str :$email?) { |
|
|
2
|
0
|
0
|
2
|
|
5
|
|
|
|
2
|
0
|
|
2
|
|
310
|
|
|
|
2
|
0
|
|
2
|
|
9
|
|
|
|
2
|
0
|
|
2
|
|
3
|
|
|
|
2
|
0
|
|
0
|
|
446
|
|
|
|
2
|
0
|
|
|
|
10
|
|
|
|
2
|
0
|
|
|
|
2
|
|
|
|
2
|
0
|
|
|
|
268
|
|
|
|
2
|
0
|
|
|
|
9
|
|
|
|
2
|
0
|
|
|
|
2
|
|
|
|
2
|
0
|
|
|
|
218
|
|
|
|
2
|
0
|
|
|
|
10
|
|
|
|
2
|
0
|
|
|
|
3
|
|
|
|
2
|
0
|
|
|
|
390
|
|
|
|
2
|
0
|
|
|
|
278
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
|
my $request; |
|
251
|
0
|
0
|
|
|
|
|
if (defined($id)) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
252
|
0
|
|
|
|
|
|
$request = DELETE($self->api_base . '/users/' . $id); |
|
253
|
|
|
|
|
|
|
} elsif (defined($user_id)) { |
|
254
|
0
|
|
|
|
|
|
$request = DELETE($self->api_base . '/users?user_id=' . URI::Escape::uri_escape($user_id)); |
|
255
|
|
|
|
|
|
|
} elsif (defined($email)) { |
|
256
|
0
|
|
|
|
|
|
$request = DELETE($self->api_base . '/users?email=' . URI::Escape::uri_escape($email)); |
|
257
|
|
|
|
|
|
|
} |
|
258
|
|
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
|
$self->_request($request); |
|
260
|
|
|
|
|
|
|
} |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head2 tag_create_or_update |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
Creates or updates a tag. |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
|
267
|
|
|
|
|
|
|
$intercom->tag_create_or_update(WebService::Intercom::Tag $tag); |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
or |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
$intercom->tag_create_or_update(Str :$name, |
|
272
|
|
|
|
|
|
|
Maybe[Str] :$id?); |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Returns a L<WebService::Intercom::Tag> that represents the tag. |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=cut |
|
277
|
|
|
|
|
|
|
|
|
278
|
2
|
0
|
|
2
|
|
4884
|
multi method tag_create_or_update(WebService::Intercom::Tag $tag) { |
|
|
2
|
0
|
|
2
|
|
4
|
|
|
|
2
|
0
|
|
0
|
|
393
|
|
|
|
2
|
0
|
|
|
|
9
|
|
|
|
2
|
0
|
|
|
|
2
|
|
|
|
2
|
0
|
|
|
|
184
|
|
|
|
2
|
0
|
|
|
|
294
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
279
|
0
|
|
|
|
|
|
return $self->tag_create_or_update(name => $tag->name, |
|
280
|
|
|
|
|
|
|
id => $tag->id); |
|
281
|
|
|
|
|
|
|
} |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
multi method tag_create_or_update(Str :$name, |
|
284
|
2
|
0
|
0
|
2
|
|
7513
|
Maybe[Str] :$id?) { |
|
|
2
|
0
|
0
|
2
|
|
5
|
|
|
|
2
|
0
|
|
2
|
|
482
|
|
|
|
2
|
0
|
|
2
|
|
10
|
|
|
|
2
|
0
|
|
0
|
|
2
|
|
|
|
2
|
0
|
|
|
|
487
|
|
|
|
2
|
0
|
|
|
|
10
|
|
|
|
2
|
0
|
|
|
|
3
|
|
|
|
2
|
0
|
|
|
|
266
|
|
|
|
2
|
0
|
|
|
|
8
|
|
|
|
2
|
0
|
|
|
|
4
|
|
|
|
2
|
0
|
|
|
|
330
|
|
|
|
2
|
|
|
|
|
388
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
285
|
0
|
|
|
|
|
|
my $json_content = { |
|
286
|
|
|
|
|
|
|
name => $name, |
|
287
|
|
|
|
|
|
|
}; |
|
288
|
0
|
0
|
|
|
|
|
if (defined($id)) { |
|
289
|
0
|
|
|
|
|
|
$json_content->{id} = $id; |
|
290
|
|
|
|
|
|
|
} |
|
291
|
|
|
|
|
|
|
|
|
292
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/tags', |
|
293
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
|
294
|
|
|
|
|
|
|
Content => JSON::XS::encode_json($json_content) |
|
295
|
|
|
|
|
|
|
); |
|
296
|
|
|
|
|
|
|
|
|
297
|
0
|
|
|
|
|
|
return $self->_request($request); |
|
298
|
|
|
|
|
|
|
} |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head2 tag_items |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
Applies or removes a tag to users or companies |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
|
306
|
|
|
|
|
|
|
$intercom->tag_items(Str :$name, |
|
307
|
|
|
|
|
|
|
ArrayRef[TagUserIdentifierType] :$users?, |
|
308
|
|
|
|
|
|
|
ArrayRef[TagCompanyIdentifierType] :$companies?); |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=cut |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
method tag_items(Str :$name, |
|
314
|
|
|
|
|
|
|
ArrayRef[TagUserIdentifierType] :$users?, |
|
315
|
2
|
0
|
0
|
2
|
|
17899
|
ArrayRef[TagCompanyIdentifierType] :$companies?) { |
|
|
2
|
0
|
0
|
2
|
|
4
|
|
|
|
2
|
0
|
0
|
2
|
|
199
|
|
|
|
2
|
0
|
0
|
2
|
|
9
|
|
|
|
2
|
0
|
0
|
2
|
|
3
|
|
|
|
2
|
0
|
0
|
0
|
|
531
|
|
|
|
2
|
0
|
0
|
|
|
12
|
|
|
|
2
|
0
|
0
|
|
|
5
|
|
|
|
2
|
0
|
0
|
|
|
215
|
|
|
|
2
|
0
|
0
|
|
|
13
|
|
|
|
2
|
0
|
0
|
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|
|
|
name => $name, |
|
319
|
|
|
|
|
|
|
}; |
|
320
|
|
|
|
|
|
|
|
|
321
|
0
|
0
|
0
|
|
|
|
if (!(defined($users) xor defined($companies))) { |
|
322
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Either users or companies must be defined as a parameter, not both and not neither"}); |
|
323
|
|
|
|
|
|
|
} |
|
324
|
|
|
|
|
|
|
|
|
325
|
0
|
0
|
|
|
|
|
if (defined($users)) { |
|
|
|
0
|
|
|
|
|
|
|
326
|
0
|
|
|
|
|
|
$json_content->{users} = $users; |
|
327
|
|
|
|
|
|
|
} elsif (defined($companies)) { |
|
328
|
0
|
|
|
|
|
|
$json_content->{companies} = $companies; |
|
329
|
|
|
|
|
|
|
} |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
|
|
332
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/tags', |
|
333
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
|
334
|
|
|
|
|
|
|
Content => JSON::XS::encode_json($json_content) |
|
335
|
|
|
|
|
|
|
); |
|
336
|
|
|
|
|
|
|
|
|
337
|
0
|
|
|
|
|
|
return $self->_request($request); |
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=head2 tag_delete |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
Deletes a tag |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
|
346
|
|
|
|
|
|
|
$intercom->tag_delete(WebService::Intercom::Tag $tag); |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
or |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
$intercom->tag_delete(Str :$id); |
|
351
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
Returns undef |
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=cut |
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
|
|
357
|
2
|
0
|
0
|
2
|
|
5415
|
multi method tag_delete(Str :$id) { |
|
|
2
|
0
|
0
|
2
|
|
5
|
|
|
|
2
|
0
|
|
2
|
|
285
|
|
|
|
2
|
0
|
|
0
|
|
8
|
|
|
|
2
|
0
|
|
|
|
3
|
|
|
|
2
|
0
|
|
|
|
445
|
|
|
|
2
|
0
|
|
|
|
8
|
|
|
|
2
|
0
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
251
|
|
|
|
2
|
|
|
|
|
254
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
358
|
0
|
|
|
|
|
|
$self->_request(DELETE($self->api_base . '/tags/' . $id), no_content => 1); |
|
359
|
|
|
|
|
|
|
} |
|
360
|
|
|
|
|
|
|
|
|
361
|
2
|
0
|
|
2
|
|
4863
|
multi method tag_delete(WebService::Intercom::Tag $tag) { |
|
|
2
|
0
|
|
2
|
|
3
|
|
|
|
2
|
0
|
|
0
|
|
429
|
|
|
|
2
|
0
|
|
|
|
9
|
|
|
|
2
|
0
|
|
|
|
2
|
|
|
|
2
|
0
|
|
|
|
184
|
|
|
|
2
|
0
|
|
|
|
277
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
362
|
0
|
|
|
|
|
|
return $self->tag_delete(id => $tag->id); |
|
363
|
|
|
|
|
|
|
} |
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=head2 note_create |
|
367
|
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
Creates a note for a user |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
|
371
|
|
|
|
|
|
|
$intercom->note_create(Maybe[Str] :$user_id?, |
|
372
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
|
373
|
|
|
|
|
|
|
Maybe[Str] :$id?, |
|
374
|
|
|
|
|
|
|
Maybe[Str] :$admin_id?, |
|
375
|
|
|
|
|
|
|
Str :$body); |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
Returns a L<WebService::Intercom::Note> that represents the note. |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
=cut |
|
380
|
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
method note_create(Maybe[Str] :$user_id?, |
|
384
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
|
385
|
|
|
|
|
|
|
Maybe[Str] :$id?, |
|
386
|
|
|
|
|
|
|
Maybe[Str] :$admin_id?, |
|
387
|
2
|
0
|
0
|
2
|
|
15121
|
Str :$body) { |
|
|
2
|
0
|
0
|
2
|
|
4
|
|
|
|
2
|
0
|
|
2
|
|
247
|
|
|
|
2
|
0
|
|
2
|
|
11
|
|
|
|
2
|
0
|
|
2
|
|
2
|
|
|
|
2
|
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))) { |
|
|
|
|
0
|
|
|
|
|
|
389
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "One and only one of user_id, email or id must be defined"}); |
|
390
|
|
|
|
|
|
|
} |
|
391
|
|
|
|
|
|
|
|
|
392
|
0
|
|
|
|
|
|
my $json_content = { |
|
393
|
|
|
|
|
|
|
body => $body, |
|
394
|
|
|
|
|
|
|
}; |
|
395
|
|
|
|
|
|
|
|
|
396
|
0
|
0
|
|
|
|
|
if (defined($user_id)) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
397
|
0
|
|
|
|
|
|
$json_content->{user}->{user_id} = $user_id; |
|
398
|
|
|
|
|
|
|
} elsif (defined($email)) { |
|
399
|
0
|
|
|
|
|
|
$json_content->{user}->{email} = $email; |
|
400
|
|
|
|
|
|
|
} elsif (defined($id)) { |
|
401
|
0
|
|
|
|
|
|
$json_content->{user}->{id} = $id; |
|
402
|
|
|
|
|
|
|
} |
|
403
|
|
|
|
|
|
|
|
|
404
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/notes', |
|
405
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
|
406
|
|
|
|
|
|
|
Content => JSON::XS::encode_json($json_content) |
|
407
|
|
|
|
|
|
|
); |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
|
|
410
|
0
|
|
|
|
|
|
return $self->_request($request); |
|
411
|
|
|
|
|
|
|
} |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
=head2 event_create |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
Creates an event for a user |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
|
418
|
|
|
|
|
|
|
$intercom->event_create(Maybe[Str] :$user_id?, |
|
419
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
|
420
|
|
|
|
|
|
|
EventNameType :$event_name, |
|
421
|
|
|
|
|
|
|
Maybe[Int] :$created_at?, |
|
422
|
|
|
|
|
|
|
Maybe[EventMetadataType] :$metadata?); |
|
423
|
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
Returns undef. |
|
425
|
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=cut |
|
427
|
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
method event_create(Maybe[Str] :$user_id?, |
|
429
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
|
430
|
|
|
|
|
|
|
EventNameType :$event_name, |
|
431
|
|
|
|
|
|
|
Maybe[Int] :$created_at?, |
|
432
|
2
|
0
|
0
|
2
|
|
18609
|
Maybe[EventMetadataType] :$metadata? where { !defined($_) || scalar(keys %$_) <= 5 }) { |
|
|
2
|
0
|
0
|
2
|
|
5
|
|
|
|
2
|
0
|
0
|
2
|
|
218
|
|
|
|
2
|
0
|
0
|
2
|
|
10
|
|
|
|
2
|
0
|
0
|
2
|
|
2
|
|
|
|
2
|
0
|
0
|
2
|
|
424
|
|
|
|
2
|
0
|
0
|
2
|
|
8
|
|
|
|
2
|
0
|
0
|
0
|
|
4
|
|
|
|
2
|
0
|
0
|
|
|
199
|
|
|
|
2
|
0
|
0
|
|
|
13
|
|
|
|
2
|
0
|
0
|
|
|
4
|
|
|
|
2
|
0
|
0
|
|
|
240
|
|
|
|
2
|
0
|
0
|
|
|
8
|
|
|
|
2
|
0
|
|
|
|
4
|
|
|
|
2
|
0
|
|
|
|
260
|
|
|
|
2
|
0
|
|
|
|
9
|
|
|
|
2
|
0
|
|
|
|
7
|
|
|
|
2
|
0
|
|
|
|
192
|
|
|
|
2
|
0
|
|
|
|
13
|
|
|
|
2
|
0
|
|
|
|
3
|
|
|
|
2
|
0
|
|
|
|
1709
|
|
|
|
2
|
0
|
|
|
|
284
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
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
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "One of user_id or email must be defined"}); |
|
436
|
|
|
|
|
|
|
} |
|
437
|
|
|
|
|
|
|
|
|
438
|
0
|
|
|
|
|
|
my $json_content = { |
|
439
|
|
|
|
|
|
|
event_name => $event_name, |
|
440
|
|
|
|
|
|
|
created_at => $created_at, |
|
441
|
|
|
|
|
|
|
}; |
|
442
|
|
|
|
|
|
|
|
|
443
|
0
|
0
|
|
|
|
|
if (defined($user_id)) { |
|
|
|
0
|
|
|
|
|
|
|
444
|
0
|
|
|
|
|
|
$json_content->{user_id} = $user_id; |
|
445
|
|
|
|
|
|
|
} elsif (defined($email)) { |
|
446
|
0
|
|
|
|
|
|
$json_content->{email} = $email; |
|
447
|
|
|
|
|
|
|
} |
|
448
|
|
|
|
|
|
|
|
|
449
|
0
|
0
|
|
|
|
|
if (defined($metadata)) { |
|
450
|
0
|
|
|
|
|
|
$json_content->{metadata} = $metadata; |
|
451
|
|
|
|
|
|
|
} |
|
452
|
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
|
|
454
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/events', |
|
455
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
|
456
|
|
|
|
|
|
|
Content => JSON::XS::encode_json($json_content) |
|
457
|
|
|
|
|
|
|
); |
|
458
|
|
|
|
|
|
|
|
|
459
|
0
|
|
|
|
|
|
return $self->_request($request, no_content => 1); |
|
460
|
|
|
|
|
|
|
} |
|
461
|
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=head2 create_message |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
Create a message, can be user or admin initiated. |
|
466
|
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
|
468
|
|
|
|
|
|
|
$intercom->create_message(MessagePersonType :$from, |
|
469
|
|
|
|
|
|
|
Maybe[MessagePersonType] :$to, |
|
470
|
|
|
|
|
|
|
Str :$body, |
|
471
|
|
|
|
|
|
|
Maybe[Str] :$subject?, |
|
472
|
|
|
|
|
|
|
Maybe[StrMatch[qr/^(plain|personal)$/]] :$template, |
|
473
|
|
|
|
|
|
|
StrMatch[qr/^(inapp|email)$/] :$message_type); |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
Returns a L<WebService::Intercom::Message>. |
|
476
|
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
=cut |
|
478
|
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
method create_message(MessagePersonType :$from, |
|
480
|
|
|
|
|
|
|
Maybe[MessagePersonType] :$to, |
|
481
|
|
|
|
|
|
|
Str :$body, |
|
482
|
|
|
|
|
|
|
Maybe[Str] :$subject?, |
|
483
|
|
|
|
|
|
|
Maybe[StrMatch[qr/^(plain|personal)$/]] :$template, |
|
484
|
2
|
0
|
0
|
2
|
|
30118
|
StrMatch[qr/^(inapp|email)$/] :$message_type) { |
|
|
2
|
0
|
0
|
2
|
|
6
|
|
|
|
2
|
0
|
0
|
2
|
|
226
|
|
|
|
2
|
0
|
0
|
2
|
|
8
|
|
|
|
2
|
0
|
0
|
2
|
|
5
|
|
|
|
2
|
0
|
0
|
2
|
|
464
|
|
|
|
2
|
0
|
0
|
2
|
|
10
|
|
|
|
2
|
0
|
0
|
2
|
|
2
|
|
|
|
2
|
0
|
0
|
0
|
|
807
|
|
|
|
2
|
0
|
0
|
|
|
10
|
|
|
|
2
|
0
|
0
|
|
|
3
|
|
|
|
2
|
0
|
0
|
|
|
832
|
|
|
|
2
|
0
|
0
|
|
|
10
|
|
|
|
2
|
0
|
0
|
|
|
3
|
|
|
|
2
|
0
|
0
|
|
|
189
|
|
|
|
2
|
0
|
0
|
|
|
7
|
|
|
|
2
|
0
|
0
|
|
|
4
|
|
|
|
2
|
0
|
0
|
|
|
198
|
|
|
|
2
|
0
|
|
|
|
9
|
|
|
|
2
|
0
|
|
|
|
3
|
|
|
|
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|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
|
|
486
|
0
|
0
|
0
|
|
|
|
if (defined($message_type) && $message_type eq 'email') { |
|
487
|
0
|
0
|
|
|
|
|
defined($subject) || WebService::Intercom::Exception->throw({ message => "Subject is required for email message"}); |
|
488
|
|
|
|
|
|
|
} |
|
489
|
|
|
|
|
|
|
|
|
490
|
0
|
0
|
|
|
|
|
my $json_content = { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
from => $from, |
|
492
|
|
|
|
|
|
|
(defined($to) ? (to => $to) : ()), |
|
493
|
|
|
|
|
|
|
(defined($subject) ? (subject => $subject) : ()), |
|
494
|
|
|
|
|
|
|
(defined($template) ? (template => $template) : ()), |
|
495
|
|
|
|
|
|
|
(defined($message_type) ? (message_type => $message_type) : ()), |
|
496
|
|
|
|
|
|
|
body => $body, |
|
497
|
|
|
|
|
|
|
}; |
|
498
|
|
|
|
|
|
|
|
|
499
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/messages', |
|
500
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
|
501
|
|
|
|
|
|
|
Content => JSON::XS::encode_json($json_content) |
|
502
|
|
|
|
|
|
|
); |
|
503
|
|
|
|
|
|
|
|
|
504
|
0
|
|
|
|
|
|
return $self->_request($request); |
|
505
|
|
|
|
|
|
|
} |
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
|
|
508
|
2
|
0
|
|
2
|
|
2379
|
method get_admins() { |
|
|
2
|
0
|
|
0
|
|
3
|
|
|
|
2
|
|
|
|
|
249
|
|
|
|
2
|
|
|
|
|
364
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
509
|
0
|
|
|
|
|
|
my $request = GET($self->api_base . '/admins/', |
|
510
|
|
|
|
|
|
|
'Content-Type' => 'application/json'); |
|
511
|
|
|
|
|
|
|
|
|
512
|
0
|
|
|
|
|
|
return $self->_request($request); |
|
513
|
|
|
|
|
|
|
} |
|
514
|
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
|
|
517
|
2
|
0
|
0
|
2
|
|
7669
|
method _request(HTTP::Request $request, Bool :$no_content?) { |
|
|
2
|
0
|
0
|
2
|
|
5
|
|
|
|
2
|
0
|
|
2
|
|
296
|
|
|
|
2
|
0
|
|
2
|
|
9
|
|
|
|
2
|
0
|
|
0
|
|
3
|
|
|
|
2
|
0
|
|
|
|
197
|
|
|
|
2
|
0
|
|
|
|
11
|
|
|
|
2
|
0
|
|
|
|
4
|
|
|
|
2
|
0
|
|
|
|
540
|
|
|
|
2
|
|
|
|
|
11
|
|
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1716
|
|
|
|
2
|
|
|
|
|
270
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
518
|
0
|
|
|
|
|
|
$request->header('Accept', 'application/json'); |
|
519
|
0
|
|
|
|
|
|
$request->header('Authorization' => "Basic " . MIME::Base64::encode_base64($self->app_id . ":" . $self->api_key, '')); |
|
520
|
|
|
|
|
|
|
|
|
521
|
0
|
|
|
|
|
|
my $response = $self->ua->request($request); |
|
522
|
|
|
|
|
|
|
|
|
523
|
0
|
0
|
|
|
|
|
if ($response->is_success()) { |
|
524
|
0
|
0
|
|
|
|
|
if (!$no_content) { |
|
525
|
0
|
|
|
|
|
|
my $data; |
|
526
|
0
|
|
|
|
|
|
eval { |
|
527
|
0
|
|
|
|
|
|
$data = JSON::XS::decode_json($response->content()); |
|
528
|
|
|
|
|
|
|
}; |
|
529
|
0
|
0
|
|
|
|
|
if ($@) { |
|
530
|
|
|
|
|
|
|
|
|
531
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Failed to decode JSON result for request " . $request->as_string() . "\nResult was: " . $response->as_string()}); |
|
532
|
|
|
|
|
|
|
} |
|
533
|
0
|
0
|
|
|
|
|
if ($data->{type} =~ /^(user|tag|note|user_message|admin_message)$/) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
534
|
0
|
|
|
|
|
|
my $name = $1; |
|
535
|
0
|
|
|
|
|
|
my $class_name = "WebService::Intercom::" . ucfirst($1); |
|
536
|
0
|
|
|
|
|
|
$class_name =~ s/(?:user_message|admin_message)$/Message/ig; |
|
537
|
0
|
|
|
|
|
|
return $class_name->new({ |
|
538
|
|
|
|
|
|
|
%$data, |
|
539
|
|
|
|
|
|
|
intercom => $self, |
|
540
|
|
|
|
|
|
|
}); |
|
541
|
|
|
|
|
|
|
} elsif ($data->{type} eq 'admin.list') { |
|
542
|
0
|
|
|
|
|
|
my @admins = map { WebService::Intercom::Admin->new($_) } @{$data->{admins}}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
543
|
0
|
|
|
|
|
|
return \@admins; |
|
544
|
|
|
|
|
|
|
} elsif ($data->{type} eq 'error.list') { |
|
545
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw( |
|
546
|
|
|
|
|
|
|
request_id => $data->{request_id}, |
|
547
|
|
|
|
|
|
|
message => $data->{errors}->[0]->{message}, |
|
548
|
|
|
|
|
|
|
code => $data->{errors}->[0]->{code} |
|
549
|
|
|
|
|
|
|
); |
|
550
|
|
|
|
|
|
|
} else { |
|
551
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Unknown object type returned: $data->{type}"}); |
|
552
|
|
|
|
|
|
|
} |
|
553
|
|
|
|
|
|
|
} |
|
554
|
0
|
|
|
|
|
|
return; |
|
555
|
|
|
|
|
|
|
} else { |
|
556
|
|
|
|
|
|
|
# Failed request but we still got some json content |
|
557
|
0
|
0
|
|
|
|
|
if ($response->header('Content-Type') =~ /json/) { |
|
558
|
0
|
|
|
|
|
|
my $data; |
|
559
|
0
|
|
|
|
|
|
eval { |
|
560
|
0
|
|
|
|
|
|
$data = JSON::XS::decode_json($response->content()); |
|
561
|
|
|
|
|
|
|
}; |
|
562
|
0
|
0
|
|
|
|
|
if ($@) { |
|
563
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Failed to decode JSON result for request " . $request->as_string() . "\nResult was: " . $response->as_string()}); |
|
564
|
|
|
|
|
|
|
} |
|
565
|
|
|
|
|
|
|
WebService::Intercom::Exception->throw( |
|
566
|
0
|
|
|
|
|
|
request_id => $data->{request_id}, |
|
567
|
|
|
|
|
|
|
message => $data->{errors}->[0]->{message}, |
|
568
|
|
|
|
|
|
|
code => $data->{errors}->[0]->{code} |
|
569
|
|
|
|
|
|
|
); |
|
570
|
|
|
|
|
|
|
} |
|
571
|
|
|
|
|
|
|
} |
|
572
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Got a bad response from request:\n" . $request->as_string() . "\nResult was: " . $response->as_string()}); |
|
573
|
|
|
|
|
|
|
} |
|
574
|
|
|
|
|
|
|
} |
|
575
|
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
1; |
|
578
|
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
__END__ |
|
580
|
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
583
|
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
See L<Moops> and L<Kavorka> to understand parameter signatures. |
|
585
|
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
Also of course Intercom at L<http://www.intercom.io>. |
|
587
|
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
=head1 AUTHOR |
|
589
|
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
Rusty Conover <rusty+cpan@luckydinosaur.com> |
|
591
|
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
593
|
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Lucky Dinosaur LLC. L<http://www.luckydinosaur.com> |
|
595
|
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. |
|
597
|
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
|
599
|
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
|
601
|
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
=cut |
|
603
|
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
1; |