Skip to content

Commit

Permalink
LiquidPlanner + HelpSpot: create HelpSpot note about new LP task
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbs committed Feb 2, 2021
1 parent df09721 commit a8bd2d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/Synergy/Reactor/HelpSpot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ sub _http_get ($self, $param) {
);
}

sub _http_post ($self, $method, $param) {
my $uri = URI->new($self->api_uri);
$uri->query_form_hash({ method => $method });

my $res = $self->hub->http_post(
$uri,
Content => [ %$param ],
Content_Type => 'application/x-www-form-urlencoded',
Authorization => 'Basic ' . $self->auth_token,
'User-Agent' => __PACKAGE__,
);
}

sub ticket_report ($self, $who, $arg = {}) {
return unless my $user_id = $self->get_user_preference($who, 'user-id');

Expand Down
10 changes: 10 additions & 0 deletions lib/Synergy/Reactor/LiquidPlanner.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,7 @@ sub task_plan_from_spec ($self, $event, $spec) {
}

if (%ptn and $self->has_ptn_expansion_format) {
$plan{helpspot_tickets} = [ keys %ptn ];
$plan{description} .= "\n\n" . sprintf $self->ptn_expansion_format, $_
for keys %ptn;
}
Expand Down Expand Up @@ -2243,6 +2244,15 @@ sub _execute_task_creation_plan ($self, $event, $plan, $error) {
$task->{item_email};
$event->reply($plain, { slack => $slack });
if ($plan->{helpspot_tickets} && $plan->{helpspot_tickets}->@*) {
if (my $helpspot = $self->hub->reactor_named('helpspot')) {
$helpspot->_http_post('private.request.update', {
tNote => "LiquidPlanner task created at $item_uri",
fNoteType => 0,
})->retain;
}
}
});
})->else(sub (@wtf) { $Logger->log("error with task creation: @wtf") })->retain;
Expand Down

0 comments on commit a8bd2d0

Please sign in to comment.