使用“ArticleCreate”触发器的“TestSimple”调用程序获取Ticket消息正文

时间:2016-05-20 17:31:44

标签: perl otrs

我正在使用触发器'ArticleCreate'的调用者TestSimple.pm。 (理想情况下应该创建一个新的调用程序!)我能够通过REST Web服务正确地接收票证的json数据。 我想要一个额外的票证属性与此 - >; '票务机构'。我如何修改调用程序(perl文件),以便它还在json数据中发送票证正文?或者他们的任何其他触发器可以给我这个开箱即用的? 我经历了OTRS手册并再次感到困惑 - 再次:( 所以,如果有人能给我正确的链接,也会这样做!

系统详情: 1. OTRS v4.0 2. Apache Web服务器

[编辑]添加了TestSimple.pm文件。 这是我提到的link

    #copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::GenericInterface::Invoker::Test::TestSimple;

use strict;
use warnings;

use Kernel::System::VariableCheck qw(IsString IsStringWithData);
use Kernel::System::Ticket;

our $ObjectManagerDisabled = 1;

=head1 NAME

Kernel::GenericInterface::Invoker::Test::Test - GenericInterface test Invoker backend

=head1 SYNOPSIS

=head1 PUBLIC INTERFACE

=over 4

=cut

=item new()

usually, you want to create an instance of this
by using Kernel::GenericInterface::Invoker->new();

=cut

sub new {
my ( $Type, %Param ) = @_;

# allocate new hash for object
my $Self = {};
bless( $Self, $Type );

# check needed params
if ( !$Param{DebuggerObject} ) {
return {
Success => 0,
ErrorMessage => "Got no DebuggerObject!"
};
}

$Self->{DebuggerObject} = $Param{DebuggerObject};
$Self->{TicketObject} = Kernel::System::Ticket->new(%Param);

return $Self;
}

=item PrepareRequest()

prepare the invocation of the configured remote webservice.
This will just return the data that was passed to the function.

my $Result = $InvokerObject->PrepareRequest(
Data => { # data payload
...
},
);

my %Article = $TicketObject->ArticleGet(
ArticleID => $Param{Data}->{ArticleID},
UserID => $Param{Data}->{CustomerID},
);

$Result = {
Success => 1, # 0 or 1
ErrorMessage => '', # in case of error
Data => { # data payload after Invoker
...
},
};

=cut

sub PrepareRequest {
my ( $Self, %Param ) = @_;
my %TicketInfo = $Self->{TicketObject}->ArticleGet(
ArticleID => $Param{Data}->{ArticleID},
userID => $Param{Data}->{CustomerID},
);

return {
Success => 1,
Data => $TicketInfo{Body},
};
}

=item HandleResponse()

handle response data of the configured remote webservice.
This will just return the data that was passed to the function.

my $Result = $InvokerObject->HandleResponse(
#my $Result = $TicketBodyObject->HandleResponse(
ResponseSuccess => 1, # success status of the remote webservice
ResponseErrorMessage => '', # in case of webservice error
Data => { # data payload
...
},
);

$Result = {
Success => 1, # 0 or 1
ErrorMessage => '', # in case of error
Data => { # data payload after Invoker
%Article
},
};

=cut

sub HandleResponse {
my ( $Self, %Param ) = @_;

# if there was an error in the response, forward it
if ( !$Param{ResponseSuccess} ) {
return {
Success => 0,
ErrorMessage => $Param{ResponseErrorMessage},
};
}

return {
Success => 1,
Data => $Param{Data},
};
}

1;

=back

=head1 TERMS AND CONDITIONS

This software is part of the OTRS project (L<http://otrs.org/>).

This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (AGPL). If you
did not receive this file, see L<http://www.gnu.org/licenses/agpl.txt>.

=cut

1 个答案:

答案 0 :(得分:0)

PrepareRequest只知道它正在运行的200m,300m,600m,700m,1000m,1100m,1400m,1500m,1800m,2200m,2600m,3000m,3400m,3800m,4200m,4600m,5000m 18.70 - (18.7),,47.50 - (28.8),,1:16.62 - (29.1),,1:45.74 - (29.1),,2:14.95 - (29.2),2:44.16 - (29.2),3:13.27 - (29.1),3:42.40 - (29.1),4:11.70 - (29.3),4:41.11 - (29.4),5:10.75 - (29.6),5:40.39 - (29.6),6:10.44 - (30.0) ,,45.92 - (27.7),,1:16.24 - (30.3),,,,,,,,,,,, ,23.51 - (23.5),,48.80 - (25.2),,1:14.96 - (26.1),,1:42.48 - (27.5),,,,,,,,, TicketID。 您需要在Invoker的ArticleID子区域中查找需要传递的数据,然后在Data参数中将其返回。

检查以下代码,了解如何添加文章正文的示例:

PrepareRequest()