line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
3052
|
use Moops -strict; |
|
2
|
|
|
|
|
89745
|
|
|
2
|
|
|
|
|
14
|
|
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
|
|
116447
|
use WebService::Intercom::Exception; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
81
|
|
72
|
2
|
|
|
2
|
|
802
|
use WebService::Intercom::Types; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
27
|
|
73
|
2
|
|
|
2
|
|
2224
|
use WebService::Intercom::User; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
140
|
|
74
|
2
|
|
|
2
|
|
684
|
use WebService::Intercom::Tag; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
94
|
|
75
|
2
|
|
|
2
|
|
829
|
use WebService::Intercom::Note; |
|
2
|
|
|
|
|
93
|
|
|
2
|
|
|
|
|
96
|
|
76
|
2
|
|
|
2
|
|
872
|
use WebService::Intercom::Message; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
97
|
|
77
|
2
|
|
|
2
|
|
914
|
use WebService::Intercom::Admin; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
155
|
|
78
|
|
|
|
|
|
|
|
79
|
2
|
|
|
2
|
|
3305
|
class WebService::Intercom types WebService::Intercom::Types { |
|
2
|
|
|
2
|
|
56
|
|
|
2
|
|
|
2
|
|
17
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
121
|
|
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
548
|
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
109
|
|
|
2
|
|
|
|
|
79
|
|
|
2
|
|
|
|
|
116
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
154
|
|
|
2
|
|
|
|
|
55
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
10795
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
845
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
292
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
135
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
360
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
22
|
|
|
2
|
|
|
|
|
1705
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
6610
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
92
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
58
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
94
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
286
|
|
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
7181
|
|
80
|
2
|
|
|
2
|
|
2263
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
86523
|
|
|
2
|
|
|
|
|
106
|
|
81
|
2
|
|
|
2
|
|
20
|
use HTTP::Response; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
82
|
2
|
|
|
2
|
|
1272
|
use HTTP::Request::Common qw(DELETE POST GET); |
|
2
|
|
|
|
|
4751
|
|
|
2
|
|
|
|
|
174
|
|
83
|
2
|
|
|
2
|
|
1290
|
use JSON::XS; |
|
2
|
|
|
|
|
9790
|
|
|
2
|
|
|
|
|
141
|
|
84
|
2
|
|
|
2
|
|
922
|
use MIME::Base64; |
|
2
|
|
|
|
|
1265
|
|
|
2
|
|
|
|
|
123
|
|
85
|
2
|
|
|
2
|
|
10
|
use Kavorka qw( multi method ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
23
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
2
|
|
|
|
|
34
|
has 'ua' => (is => 'ro', default => sub { return LWP::UserAgent->new(keep_alive => 10, agent => "WebService::Intercom/1.0") } ); |
|
0
|
|
|
|
|
0
|
|
89
|
2
|
|
|
|
|
1295
|
has 'app_id' => (is => 'ro'); |
90
|
2
|
|
|
|
|
499
|
has 'api_key' => (is => 'ro'); |
91
|
|
|
|
|
|
|
|
92
|
2
|
|
|
|
|
501
|
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
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
method user_get(Maybe[Str] :$user_id?, |
112
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
113
|
2
|
0
|
0
|
2
|
|
15848
|
Maybe[Str] :$id?) { |
|
2
|
0
|
0
|
2
|
|
5
|
|
|
2
|
0
|
|
2
|
|
228
|
|
|
2
|
0
|
|
2
|
|
10
|
|
|
2
|
0
|
|
2
|
|
2
|
|
|
2
|
0
|
|
0
|
|
527
|
|
|
2
|
0
|
|
|
|
9
|
|
|
2
|
0
|
|
|
|
2
|
|
|
2
|
0
|
|
|
|
267
|
|
|
2
|
0
|
|
|
|
12
|
|
|
2
|
0
|
|
|
|
3
|
|
|
2
|
|
|
|
|
326
|
|
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
564
|
|
|
2
|
|
|
|
|
643
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
0
|
0
|
0
|
|
|
|
if (!(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
|
|
5679
|
multi method user_create_or_update(WebService::Intercom::User $user) { |
|
2
|
0
|
|
2
|
|
4
|
|
|
2
|
0
|
|
0
|
|
419
|
|
|
2
|
0
|
|
|
|
8
|
|
|
2
|
0
|
|
|
|
4
|
|
|
2
|
0
|
|
|
|
260
|
|
|
2
|
0
|
|
|
|
393
|
|
|
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
|
|
|
|
|
|
|
Maybe[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
|
|
|
|
|
|
|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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
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
my $json_content = { |
188
|
|
|
|
|
|
|
signed_up_at => $signed_up_at, |
189
|
|
|
|
|
|
|
name => $name, |
190
|
|
|
|
|
|
|
last_seen_ip => $last_seen_ip, |
191
|
|
|
|
|
|
|
custom_attributes => $custom_attributes, |
192
|
|
|
|
|
|
|
last_seen_user_agent => $last_seen_user_agent, |
193
|
|
|
|
|
|
|
companies => $companies, |
194
|
|
|
|
|
|
|
last_request_at => $last_request_at, |
195
|
|
|
|
|
|
|
unsubscribed_from_emails => $unsubscribed_from_emails, |
196
|
|
|
|
|
|
|
update_last_request_at => $update_last_request_at, |
197
|
|
|
|
|
|
|
new_session => $new_session |
198
|
|
|
|
|
|
|
}; |
199
|
|
|
|
|
|
|
|
200
|
0
|
0
|
|
|
|
|
if (defined($user_id)) { |
201
|
0
|
|
|
|
|
|
$json_content->{user_id} = $user_id; |
202
|
|
|
|
|
|
|
} |
203
|
0
|
0
|
|
|
|
|
if (defined($email)) { |
204
|
0
|
|
|
|
|
|
$json_content->{email} = $email; |
205
|
|
|
|
|
|
|
} |
206
|
0
|
0
|
|
|
|
|
if (defined($id)) { |
207
|
0
|
|
|
|
|
|
$json_content->{id} = $id; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
my $json = JSON::XS::encode_json($json_content); |
211
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/users', |
212
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
213
|
|
|
|
|
|
|
Content => $json |
214
|
|
|
|
|
|
|
); |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
$self->_request($request); |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head2 user_delete |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Deletes a user |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
225
|
|
|
|
|
|
|
$intercom->user_delete(WebService::Intercom::User $user); |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
or |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
$intercom->user_delete(Maybe[Str] :$user_id?, |
230
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
231
|
|
|
|
|
|
|
Maybe[Str] :$id?); |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Only one of user_id, email or id is required. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Returns a L<WebService::Intercom::User> that represents the deleted user. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=cut |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
2
|
0
|
|
2
|
|
5552
|
multi method user_delete(WebService::Intercom::User $user) { |
|
2
|
0
|
|
2
|
|
5
|
|
|
2
|
0
|
|
0
|
|
430
|
|
|
2
|
0
|
|
|
|
9
|
|
|
2
|
0
|
|
|
|
2
|
|
|
2
|
0
|
|
|
|
243
|
|
|
2
|
0
|
|
|
|
380
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
|
return $self->user_delete(user_id => $user->user_id, |
242
|
|
|
|
|
|
|
id => $user->id, |
243
|
|
|
|
|
|
|
email => $user->email); |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
multi method user_delete(Str :$user_id?, |
247
|
|
|
|
|
|
|
Str :$id?, |
248
|
2
|
0
|
0
|
2
|
|
9366
|
Str :$email?) { |
|
2
|
0
|
0
|
2
|
|
4
|
|
|
2
|
0
|
|
2
|
|
310
|
|
|
2
|
0
|
|
2
|
|
9
|
|
|
2
|
0
|
|
2
|
|
2
|
|
|
2
|
0
|
|
0
|
|
470
|
|
|
2
|
0
|
|
|
|
9
|
|
|
2
|
0
|
|
|
|
7
|
|
|
2
|
0
|
|
|
|
284
|
|
|
2
|
0
|
|
|
|
9
|
|
|
2
|
0
|
|
|
|
4
|
|
|
2
|
0
|
|
|
|
227
|
|
|
2
|
0
|
|
|
|
9
|
|
|
2
|
0
|
|
|
|
2
|
|
|
2
|
0
|
|
|
|
450
|
|
|
2
|
0
|
|
|
|
367
|
|
|
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
|
|
|
|
|
|
|
249
|
0
|
|
|
|
|
|
my $request; |
250
|
0
|
0
|
|
|
|
|
if (defined($id)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
251
|
0
|
|
|
|
|
|
$request = DELETE($self->api_base . '/users/' . $id); |
252
|
|
|
|
|
|
|
} elsif (defined($user_id)) { |
253
|
0
|
|
|
|
|
|
$request = DELETE($self->api_base . '/users?user_id=' . URI::Escape::uri_escape($user_id)); |
254
|
|
|
|
|
|
|
} elsif (defined($email)) { |
255
|
0
|
|
|
|
|
|
$request = DELETE($self->api_base . '/users?email=' . URI::Escape::uri_escape($email)); |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
0
|
|
|
|
|
|
$self->_request($request); |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head2 tag_create_or_update |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Creates or updates a tag. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
266
|
|
|
|
|
|
|
$intercom->tag_create_or_update(WebService::Intercom::Tag $tag); |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
or |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
$intercom->tag_create_or_update(Str :$name, |
271
|
|
|
|
|
|
|
Maybe[Str] :$id?); |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Returns a L<WebService::Intercom::Tag> that represents the tag. |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=cut |
276
|
|
|
|
|
|
|
|
277
|
2
|
0
|
|
2
|
|
5167
|
multi method tag_create_or_update(WebService::Intercom::Tag $tag) { |
|
2
|
0
|
|
2
|
|
4
|
|
|
2
|
0
|
|
0
|
|
444
|
|
|
2
|
0
|
|
|
|
10
|
|
|
2
|
0
|
|
|
|
3
|
|
|
2
|
0
|
|
|
|
194
|
|
|
2
|
0
|
|
|
|
307
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
278
|
0
|
|
|
|
|
|
return $self->tag_create_or_update(name => $tag->name, |
279
|
|
|
|
|
|
|
id => $tag->id); |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
multi method tag_create_or_update(Str :$name, |
283
|
2
|
0
|
0
|
2
|
|
8096
|
Maybe[Str] :$id?) { |
|
2
|
0
|
0
|
2
|
|
5
|
|
|
2
|
0
|
|
2
|
|
330
|
|
|
2
|
0
|
|
2
|
|
9
|
|
|
2
|
0
|
|
0
|
|
3
|
|
|
2
|
0
|
|
|
|
494
|
|
|
2
|
0
|
|
|
|
14
|
|
|
2
|
0
|
|
|
|
4
|
|
|
2
|
0
|
|
|
|
316
|
|
|
2
|
0
|
|
|
|
14
|
|
|
2
|
0
|
|
|
|
3
|
|
|
2
|
0
|
|
|
|
373
|
|
|
2
|
|
|
|
|
336
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
284
|
0
|
|
|
|
|
|
my $json_content = { |
285
|
|
|
|
|
|
|
name => $name, |
286
|
|
|
|
|
|
|
}; |
287
|
0
|
0
|
|
|
|
|
if (defined($id)) { |
288
|
0
|
|
|
|
|
|
$json_content->{id} = $id; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/tags', |
292
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
293
|
|
|
|
|
|
|
Content => JSON::XS::encode_json($json_content) |
294
|
|
|
|
|
|
|
); |
295
|
|
|
|
|
|
|
|
296
|
0
|
|
|
|
|
|
return $self->_request($request); |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=head2 tag_items |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
Applies or removes a tag to users or companies |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
305
|
|
|
|
|
|
|
$intercom->tag_items(Str :$name, |
306
|
|
|
|
|
|
|
ArrayRef[TagUserIdentifierType] :$users?, |
307
|
|
|
|
|
|
|
ArrayRef[TagCompanyIdentifierType] :$companies?); |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=cut |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
method tag_items(Str :$name, |
313
|
|
|
|
|
|
|
ArrayRef[TagUserIdentifierType] :$users?, |
314
|
2
|
0
|
0
|
2
|
|
19333
|
ArrayRef[TagCompanyIdentifierType] :$companies?) { |
|
2
|
0
|
0
|
2
|
|
5
|
|
|
2
|
0
|
0
|
2
|
|
223
|
|
|
2
|
0
|
0
|
2
|
|
9
|
|
|
2
|
0
|
0
|
2
|
|
4
|
|
|
2
|
0
|
0
|
0
|
|
620
|
|
|
2
|
0
|
0
|
|
|
10
|
|
|
2
|
0
|
0
|
|
|
2
|
|
|
2
|
0
|
0
|
|
|
217
|
|
|
2
|
0
|
0
|
|
|
8
|
|
|
2
|
0
|
0
|
|
|
3
|
|
|
2
|
0
|
0
|
|
|
918
|
|
|
2
|
0
|
0
|
|
|
9
|
|
|
2
|
0
|
0
|
|
|
3
|
|
|
2
|
0
|
0
|
|
|
1167
|
|
|
2
|
0
|
0
|
|
|
391
|
|
|
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
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
|
316
|
0
|
|
|
|
|
|
my $json_content = { |
317
|
|
|
|
|
|
|
name => $name, |
318
|
|
|
|
|
|
|
}; |
319
|
|
|
|
|
|
|
|
320
|
0
|
0
|
0
|
|
|
|
if (!(defined($users) xor defined($companies))) { |
321
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Either users or companies must be defined as a parameter, not both and not neither"}); |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
|
324
|
0
|
0
|
|
|
|
|
if (defined($users)) { |
|
|
0
|
|
|
|
|
|
325
|
0
|
|
|
|
|
|
$json_content->{users} = $users; |
326
|
|
|
|
|
|
|
} elsif (defined($companies)) { |
327
|
0
|
|
|
|
|
|
$json_content->{companies} = $companies; |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
|
331
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/tags', |
332
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
333
|
|
|
|
|
|
|
Content => JSON::XS::encode_json($json_content) |
334
|
|
|
|
|
|
|
); |
335
|
|
|
|
|
|
|
|
336
|
0
|
|
|
|
|
|
return $self->_request($request); |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
=head2 tag_delete |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
Deletes a tag |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
345
|
|
|
|
|
|
|
$intercom->tag_delete(WebService::Intercom::Tag $tag); |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
or |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
$intercom->tag_delete(Str :$id); |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
Returns undef |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=cut |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
|
356
|
2
|
0
|
0
|
2
|
|
5726
|
multi method tag_delete(Str :$id) { |
|
2
|
0
|
0
|
2
|
|
4
|
|
|
2
|
0
|
|
2
|
|
311
|
|
|
2
|
0
|
|
0
|
|
9
|
|
|
2
|
0
|
|
|
|
4
|
|
|
2
|
0
|
|
|
|
497
|
|
|
2
|
0
|
|
|
|
9
|
|
|
2
|
0
|
|
|
|
7
|
|
|
2
|
|
|
|
|
284
|
|
|
2
|
|
|
|
|
251
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
357
|
0
|
|
|
|
|
|
$self->_request(DELETE($self->api_base . '/tags/' . $id), no_content => 1); |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
|
360
|
2
|
0
|
|
2
|
|
5205
|
multi method tag_delete(WebService::Intercom::Tag $tag) { |
|
2
|
0
|
|
2
|
|
4
|
|
|
2
|
0
|
|
0
|
|
458
|
|
|
2
|
0
|
|
|
|
10
|
|
|
2
|
0
|
|
|
|
4
|
|
|
2
|
0
|
|
|
|
245
|
|
|
2
|
0
|
|
|
|
284
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
361
|
0
|
|
|
|
|
|
return $self->tag_delete(id => $tag->id); |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
=head2 note_create |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
Creates a note for a user |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
370
|
|
|
|
|
|
|
$intercom->note_create(Maybe[Str] :$user_id?, |
371
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
372
|
|
|
|
|
|
|
Maybe[Str] :$id?, |
373
|
|
|
|
|
|
|
Maybe[Str] :$admin_id?, |
374
|
|
|
|
|
|
|
Str :$body); |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
Returns a L<WebService::Intercom::Note> that represents the note. |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
=cut |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
|
381
|
|
|
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|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
387
|
0
|
0
|
0
|
|
|
|
if (!(defined($user_id) xor defined($email) xor defined($id))) { |
|
|
|
0
|
|
|
|
|
388
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "One and only one of user_id, email or id must be defined"}); |
389
|
|
|
|
|
|
|
} |
390
|
|
|
|
|
|
|
|
391
|
0
|
|
|
|
|
|
my $json_content = { |
392
|
|
|
|
|
|
|
body => $body, |
393
|
|
|
|
|
|
|
}; |
394
|
|
|
|
|
|
|
|
395
|
0
|
0
|
|
|
|
|
if (defined($user_id)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
396
|
0
|
|
|
|
|
|
$json_content->{user}->{user_id} = $user_id; |
397
|
|
|
|
|
|
|
} elsif (defined($email)) { |
398
|
0
|
|
|
|
|
|
$json_content->{user}->{email} = $email; |
399
|
|
|
|
|
|
|
} elsif (defined($id)) { |
400
|
0
|
|
|
|
|
|
$json_content->{user}->{id} = $id; |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/notes', |
404
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
405
|
|
|
|
|
|
|
Content => JSON::XS::encode_json($json_content) |
406
|
|
|
|
|
|
|
); |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
|
409
|
0
|
|
|
|
|
|
return $self->_request($request); |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=head2 event_create |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
Creates an event for a user |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
417
|
|
|
|
|
|
|
$intercom->event_create(Maybe[Str] :$user_id?, |
418
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
419
|
|
|
|
|
|
|
EventNameType :$event_name, |
420
|
|
|
|
|
|
|
Maybe[Int] :$created_at?, |
421
|
|
|
|
|
|
|
Maybe[EventMetadataType] :$metadata?); |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
Returns undef. |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=cut |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
method event_create(Maybe[Str] :$user_id?, |
428
|
|
|
|
|
|
|
Maybe[Str] :$email?, |
429
|
|
|
|
|
|
|
EventNameType :$event_name, |
430
|
|
|
|
|
|
|
Maybe[Int] :$created_at?, |
431
|
2
|
0
|
0
|
2
|
|
20547
|
Maybe[EventMetadataType] :$metadata? where { !defined($_) || scalar(keys %$_) <= 5 }) { |
|
2
|
0
|
0
|
2
|
|
5
|
|
|
2
|
0
|
0
|
2
|
|
221
|
|
|
2
|
0
|
0
|
2
|
|
10
|
|
|
2
|
0
|
0
|
2
|
|
3
|
|
|
2
|
0
|
0
|
2
|
|
461
|
|
|
2
|
0
|
0
|
2
|
|
11
|
|
|
2
|
0
|
0
|
0
|
|
6
|
|
|
2
|
0
|
0
|
|
|
209
|
|
|
2
|
0
|
0
|
|
|
17
|
|
|
2
|
0
|
0
|
|
|
4
|
|
|
2
|
0
|
0
|
|
|
324
|
|
|
2
|
0
|
0
|
|
|
9
|
|
|
2
|
0
|
|
|
|
2
|
|
|
2
|
0
|
|
|
|
288
|
|
|
2
|
0
|
|
|
|
10
|
|
|
2
|
0
|
|
|
|
3
|
|
|
2
|
0
|
|
|
|
215
|
|
|
2
|
0
|
|
|
|
8
|
|
|
2
|
0
|
|
|
|
10
|
|
|
2
|
0
|
|
|
|
1781
|
|
|
2
|
0
|
|
|
|
249
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
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
|
|
|
|
} |
436
|
|
|
|
|
|
|
|
437
|
0
|
|
|
|
|
|
my $json_content = { |
438
|
|
|
|
|
|
|
event_name => $event_name, |
439
|
|
|
|
|
|
|
created_at => $created_at, |
440
|
|
|
|
|
|
|
}; |
441
|
|
|
|
|
|
|
|
442
|
0
|
0
|
|
|
|
|
if (defined($user_id)) { |
|
|
0
|
|
|
|
|
|
443
|
0
|
|
|
|
|
|
$json_content->{user_id} = $user_id; |
444
|
|
|
|
|
|
|
} elsif (defined($email)) { |
445
|
0
|
|
|
|
|
|
$json_content->{email} = $email; |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
0
|
0
|
|
|
|
|
if (defined($metadata)) { |
449
|
0
|
|
|
|
|
|
$json_content->{metadata} = $metadata; |
450
|
|
|
|
|
|
|
} |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
|
453
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/events', |
454
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
455
|
|
|
|
|
|
|
Content => JSON::XS::encode_json($json_content) |
456
|
|
|
|
|
|
|
); |
457
|
|
|
|
|
|
|
|
458
|
0
|
|
|
|
|
|
return $self->_request($request, no_content => 1); |
459
|
|
|
|
|
|
|
} |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
=head2 create_message |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
Create a message, can be user or admin initiated. |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
# When you have an existing WebService::Intercom::User |
467
|
|
|
|
|
|
|
$intercom->create_message(MessagePersonType :$from, |
468
|
|
|
|
|
|
|
Maybe[MessagePersonType] :$to, |
469
|
|
|
|
|
|
|
Str :$body, |
470
|
|
|
|
|
|
|
Maybe[Str] :$subject?, |
471
|
|
|
|
|
|
|
Maybe[StrMatch[qr/^(plain|personal)$/]] :$template, |
472
|
|
|
|
|
|
|
StrMatch[qr/^(inapp|email)$/] :$message_type); |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
Returns a L<WebService::Intercom::Message>. |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
=cut |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
method create_message(MessagePersonType :$from, |
479
|
|
|
|
|
|
|
Maybe[MessagePersonType] :$to, |
480
|
|
|
|
|
|
|
Str :$body, |
481
|
|
|
|
|
|
|
Maybe[Str] :$subject?, |
482
|
|
|
|
|
|
|
Maybe[StrMatch[qr/^(plain|personal)$/]] :$template, |
483
|
2
|
0
|
0
|
2
|
|
33463
|
StrMatch[qr/^(inapp|email)$/] :$message_type) { |
|
2
|
0
|
0
|
2
|
|
5
|
|
|
2
|
0
|
0
|
2
|
|
260
|
|
|
2
|
0
|
0
|
2
|
|
9
|
|
|
2
|
0
|
0
|
2
|
|
4
|
|
|
2
|
0
|
0
|
2
|
|
520
|
|
|
2
|
0
|
0
|
2
|
|
10
|
|
|
2
|
0
|
0
|
2
|
|
2
|
|
|
2
|
0
|
0
|
0
|
|
827
|
|
|
2
|
0
|
0
|
|
|
10
|
|
|
2
|
0
|
0
|
|
|
2
|
|
|
2
|
0
|
0
|
|
|
1120
|
|
|
2
|
0
|
0
|
|
|
13
|
|
|
2
|
0
|
0
|
|
|
3
|
|
|
2
|
0
|
0
|
|
|
238
|
|
|
2
|
0
|
0
|
|
|
9
|
|
|
2
|
0
|
0
|
|
|
4
|
|
|
2
|
0
|
0
|
|
|
208
|
|
|
2
|
0
|
|
|
|
8
|
|
|
2
|
0
|
|
|
|
5
|
|
|
2
|
0
|
|
|
|
382
|
|
|
2
|
0
|
|
|
|
9
|
|
|
2
|
0
|
|
|
|
3
|
|
|
2
|
0
|
|
|
|
608
|
|
|
2
|
0
|
|
|
|
299
|
|
|
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
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
|
485
|
0
|
0
|
0
|
|
|
|
if (defined($message_type) && $message_type eq 'email') { |
486
|
0
|
0
|
|
|
|
|
defined($subject) || WebService::Intercom::Exception->throw({ message => "Subject is required for email message"}); |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
|
489
|
0
|
0
|
|
|
|
|
my $json_content = { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
490
|
|
|
|
|
|
|
from => $from, |
491
|
|
|
|
|
|
|
(defined($to) ? (to => $to) : ()), |
492
|
|
|
|
|
|
|
(defined($subject) ? (subject => $subject) : ()), |
493
|
|
|
|
|
|
|
(defined($template) ? (template => $template) : ()), |
494
|
|
|
|
|
|
|
(defined($message_type) ? (message_type => $message_type) : ()), |
495
|
|
|
|
|
|
|
body => $body, |
496
|
|
|
|
|
|
|
}; |
497
|
|
|
|
|
|
|
|
498
|
0
|
|
|
|
|
|
my $request = POST($self->api_base . '/messages', |
499
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
500
|
|
|
|
|
|
|
Content => JSON::XS::encode_json($json_content) |
501
|
|
|
|
|
|
|
); |
502
|
|
|
|
|
|
|
|
503
|
0
|
|
|
|
|
|
return $self->_request($request); |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
|
507
|
2
|
0
|
|
2
|
|
2375
|
method get_admins() { |
|
2
|
0
|
|
0
|
|
4
|
|
|
2
|
|
|
|
|
220
|
|
|
2
|
|
|
|
|
332
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
508
|
0
|
|
|
|
|
|
my $request = GET($self->api_base . '/admins/', |
509
|
|
|
|
|
|
|
'Content-Type' => 'application/json'); |
510
|
|
|
|
|
|
|
|
511
|
0
|
|
|
|
|
|
return $self->_request($request); |
512
|
|
|
|
|
|
|
} |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
|
516
|
2
|
0
|
0
|
2
|
|
7285
|
method _request(HTTP::Request $request, Bool :$no_content?) { |
|
2
|
0
|
0
|
2
|
|
6
|
|
|
2
|
0
|
|
2
|
|
362
|
|
|
2
|
0
|
|
2
|
|
9
|
|
|
2
|
0
|
|
0
|
|
4
|
|
|
2
|
0
|
|
|
|
157
|
|
|
2
|
0
|
|
|
|
8
|
|
|
2
|
0
|
|
|
|
2
|
|
|
2
|
0
|
|
|
|
411
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1642
|
|
|
2
|
|
|
|
|
226
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
517
|
0
|
|
|
|
|
|
$request->header('Accept', 'application/json'); |
518
|
0
|
|
|
|
|
|
$request->header('Authorization' => "Basic " . MIME::Base64::encode_base64($self->app_id . ":" . $self->api_key, '')); |
519
|
|
|
|
|
|
|
|
520
|
0
|
|
|
|
|
|
my $response = $self->ua->request($request); |
521
|
|
|
|
|
|
|
|
522
|
0
|
0
|
|
|
|
|
if ($response->is_success()) { |
523
|
0
|
0
|
|
|
|
|
if (!$no_content) { |
524
|
0
|
|
|
|
|
|
my $data; |
525
|
0
|
|
|
|
|
|
eval { |
526
|
0
|
|
|
|
|
|
$data = JSON::XS::decode_json($response->content()); |
527
|
|
|
|
|
|
|
}; |
528
|
0
|
0
|
|
|
|
|
if ($@) { |
529
|
|
|
|
|
|
|
|
530
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Failed to decode JSON result for request " . $request->as_string() . "\nResult was: " . $response->as_string()}); |
531
|
|
|
|
|
|
|
} |
532
|
0
|
0
|
|
|
|
|
if ($data->{type} =~ /^(user|tag|note|user_message|admin_message)$/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
533
|
0
|
|
|
|
|
|
my $class_name = "WebService::Intercom::" . ucfirst($1); |
534
|
0
|
|
|
|
|
|
$class_name =~ s/(?:user_message|admin_message)$/Message/ig; |
535
|
0
|
|
|
|
|
|
my $r; |
536
|
0
|
|
|
|
|
|
eval { |
537
|
0
|
|
|
|
|
|
$r = $class_name->new({ |
538
|
|
|
|
|
|
|
%$data, |
539
|
|
|
|
|
|
|
intercom => $self, |
540
|
|
|
|
|
|
|
}); |
541
|
|
|
|
|
|
|
}; |
542
|
0
|
0
|
|
|
|
|
if ($@) { |
543
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Failed to decode JSON result to object " . $request->as_string() . "\nResult was: " . $response->as_string()}); |
544
|
|
|
|
|
|
|
} |
545
|
0
|
|
|
|
|
|
return $r; |
546
|
|
|
|
|
|
|
} elsif ($data->{type} eq 'admin.list') { |
547
|
0
|
|
|
|
|
|
my @admins = map { WebService::Intercom::Admin->new($_) } @{$data->{admins}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
548
|
0
|
|
|
|
|
|
return \@admins; |
549
|
|
|
|
|
|
|
} elsif ($data->{type} eq 'error.list') { |
550
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw( |
551
|
|
|
|
|
|
|
request_id => $data->{request_id}, |
552
|
|
|
|
|
|
|
message => $data->{errors}->[0]->{message}, |
553
|
|
|
|
|
|
|
code => $data->{errors}->[0]->{code} |
554
|
|
|
|
|
|
|
); |
555
|
|
|
|
|
|
|
} else { |
556
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Unknown object type returned: $data->{type}"}); |
557
|
|
|
|
|
|
|
} |
558
|
|
|
|
|
|
|
} |
559
|
0
|
|
|
|
|
|
return; |
560
|
|
|
|
|
|
|
} else { |
561
|
|
|
|
|
|
|
# Failed request but we still got some json content |
562
|
0
|
0
|
|
|
|
|
if ($response->header('Content-Type') =~ /json/) { |
563
|
0
|
|
|
|
|
|
my $data; |
564
|
0
|
|
|
|
|
|
eval { |
565
|
0
|
|
|
|
|
|
$data = JSON::XS::decode_json($response->content()); |
566
|
|
|
|
|
|
|
}; |
567
|
0
|
0
|
|
|
|
|
if ($@) { |
568
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Failed to decode JSON result for request " . $request->as_string() . "\nResult was: " . $response->as_string()}); |
569
|
|
|
|
|
|
|
} |
570
|
|
|
|
|
|
|
WebService::Intercom::Exception->throw( |
571
|
0
|
|
|
|
|
|
request_id => $data->{request_id}, |
572
|
|
|
|
|
|
|
message => $data->{errors}->[0]->{message}, |
573
|
|
|
|
|
|
|
code => $data->{errors}->[0]->{code} |
574
|
|
|
|
|
|
|
); |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
} |
577
|
0
|
|
|
|
|
|
WebService::Intercom::Exception->throw({ message => "Got a bad response from request:\n" . $request->as_string() . "\nResult was: " . $response->as_string()}); |
578
|
|
|
|
|
|
|
} |
579
|
|
|
|
|
|
|
} |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
1; |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
__END__ |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=head1 SEE ALSO |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
See L<Moops> and L<Kavorka> to understand parameter signatures. |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
Also of course Intercom at L<http://www.intercom.io>. |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
=head1 AUTHOR |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
Rusty Conover <rusty+cpan@luckydinosaur.com> |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=head1 COPYRIGHT |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Lucky Dinosaur LLC. L<http://www.luckydinosaur.com> |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
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. |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
=cut |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
1; |