
############
TicketCreate
############


****
NAME
****


Kernel::GenericInterface::Operation::Ticket::TicketCreate - GenericInterface Ticket TicketCreate Operation backend


****************
PUBLIC INTERFACE
****************


new()
=====


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


Run()
=====


perform TicketCreate Operation. This will return the created ticket number.


.. code-block:: perl

     my $Result = $OperationObject->Run(
         Data => {
             UserLogin         => 'some agent login',                            # UserLogin or CustomerUserLogin or SessionID is
                                                                                 #   required
             CustomerUserLogin => 'some customer login',
             SessionID         => 123,
 
             Password  => 'some password',                                       # if UserLogin or CustomerUserLogin is sent then
                                                                                 #   Password is required
 
             Ticket => {
                 Title      => 'some ticket title',
 
                 QueueID       => 123,                                           # QueueID or Queue is required
                 Queue         => 'some queue name',
 
                 LockID        => 123,                                           # optional
                 Lock          => 'some lock name',                              # optional
                 TypeID        => 123,                                           # optional
                 Type          => 'some type name',                              # optional
                 ServiceID     => 123,                                           # optional
                 Service       => 'some service name',                           # optional
                 SLAID         => 123,                                           # optional
                 SLA           => 'some SLA name',                               # optional
 
                 StateID       => 123,                                           # StateID or State is required
                 State         => 'some state name',
 
                 PriorityID    => 123,                                           # PriorityID or Priority is required
                 Priority      => 'some priority name',
 
                 OwnerID       => 123,                                           # optional
                 Owner         => 'some user login',                             # optional
                 ResponsibleID => 123,                                           # optional
                 Responsible   => 'some user login',                             # optional
                 CustomerUser  => 'some customer user login',
 
                 PendingTime {       # optional
                     Year   => 2011,
                     Month  => 12,
                     Day    => 03,
                     Hour   => 23,
                     Minute => 05,
                 },
                 # or
                 # PendingTime {
                 #     Diff => 10080, # Pending time in minutes
                 #},
             },
             Article => {
                 CommunicationChannel            => 'Email',                    # optional
                 CommunicationChannelID          => 1,                          # optional
                 IsVisibleForCustomer            => 1,                          # optional
                 SenderTypeID                    => 123,                        # optional
                 SenderType                      => 'some sender type name',    # optional
                 AutoResponseType                => 'some auto response type',  # optional
                 ArticleSend                     => 1,                          # optional
                 From                            => 'some from string',         # optional
                 To                              => 'some to address',          # optional, required if ArticleSend => 1
                 Cc                              => 'some Cc address',          # optional
                 Bcc                             => 'some Bcc address',         # optional
                 Subject                         => 'some subject',
                 Body                            => 'some body',
                 ContentType                     => 'some content type',        # ContentType or MimeType and Charset is required
                 MimeType                        => 'some mime type',
                 Charset                         => 'some charset',
                 HistoryType                     => 'some history type',        # optional
                 HistoryComment                  => 'Some  history comment',    # optional
                 TimeUnit                        => 123,                        # optional
                 NoAgentNotify                   => 1,                          # optional
                 ForceNotificationToUserID       => [1, 2, 3]                   # optional
                 ExcludeNotificationToUserID     => [1, 2, 3]                   # optional
                 ExcludeMuteNotificationToUserID => [1, 2, 3]                   # optional
                 AppendSignatureToBody           => 1,                          # optional, defaults to 1
                 Attachment => [
                     {
                         Content     => 'content'                                 # base64 encoded
                         ContentType => 'some content type'
                         Filename    => 'some fine name'
                     },
                     # ...
                 ],
                 # or:
                 Attachment => {
                     Content     => 'content'                                 # base64 encoded
                     ContentType => 'some content type'
                     Filename    => 'some fine name'
                 },
 
                 # Signing and encryption, only used when ArticleSend is set to 1
                 Sign => {
                     Type    => 'PGP',
                     SubType => 'Inline|Detached',
                     Key     => '81877F5E',
                     Type    => 'SMIME',
                     Key     => '3b630c80',
                 },
                 Crypt => {
                     Type    => 'PGP',
                     SubType => 'Inline|Detached',
                     Key     => '81877F5E',
                     Type    => 'SMIME',
                     Key     => '3b630c80',
                 },
             },
 
             # or array of articles:
             Article => [
                 {
                     CommunicationChannel            => 'Email',                    # optional
                     CommunicationChannelID          => 1,                          # optional
                     IsVisibleForCustomer            => 1,                          # optional
                     SenderTypeID                    => 123,                        # optional
                     SenderType                      => 'some sender type name',    # optional
                     AutoResponseType                => 'some auto response type',  # optional
                     From                            => 'some from string',         # optional
                     Subject                         => 'some subject',
                     Body                            => 'some body',
                     ContentType                     => 'some content type',        # ContentType or MimeType and Charset is required
                     MimeType                        => 'some mime type',
                     Charset                         => 'some charset',
                     HistoryType                     => 'some history type',        # optional
                     HistoryComment                  => 'Some  history comment',    # optional
                     TimeUnit                        => 123,                        # optional
                     NoAgentNotify                   => 1,                          # optional
                     ForceNotificationToUserID       => [1, 2, 3]                   # optional
                     ExcludeNotificationToUserID     => [1, 2, 3]                   # optional
                     ExcludeMuteNotificationToUserID => [1, 2, 3]                   # optional
                     AppendSignatureToBody           => 1,                          # optional, defaults to 1
                     Attachment => [
                         {
                             Content     => 'content',                                # base64 encoded
                             ContentType => 'some content type',
                             Filename    => 'some fine name'
                         },
                         # ...
                     ],
                     # or:
                     Attachment => {
                         Content     => 'content'                                 # base64 encoded
                         ContentType => 'some content type'
                         Filename    => 'some fine name'
                     },
                 },
                 # ...
             ],
 
 
             DynamicField => [                                                  # optional
                 {
                     Name   => 'some name',
                     Value  => $Value,                                          # value type depends on the dynamic field
                 },
                 # ...
             ],
             # or
             # DynamicField => {
             #    Name   => 'some name',
             #    Value  => $Value,
             #},
 
             Attachment => [
                 {
                     Content     => 'content',                                # base64 encoded
                     ContentType => 'some content type',
                     Filename    => 'some fine name'
                 },
                 # ...
             ],
             #or
             #Attachment => {
             #    Content     => 'content',
             #    ContentType => 'some content type',
             #    Filename    => 'some fine name'
             #},
         },
     );
 
     $Result = {
         Success         => 1,                       # 0 or 1
         ErrorMessage    => '',                      # in case of error
         Data            => {                        # result data payload after Operation
             TicketID    => 123,                     # Ticket ID Znuny
             TicketNumber => 2324454323322,          # Ticket number in Znuny
             ArticleID   => 43,                      # Article ID in Znuny
             Error => {                              # should not return errors
                     ErrorCode    => 'Ticket.Create.ErrorCode',
                     ErrorMessage => 'Error Description'
             },
 
             # If IncludeTicketData is enabled
             Ticket => [
                 {
                     TicketNumber       => '20101027000001',
                     Title              => 'some title',
                     TicketID           => 123,
                     State              => 'some state',
                     StateID            => 123,
                     StateType          => 'some state type',
                     Priority           => 'some priority',
                     PriorityID         => 123,
                     Lock               => 'lock',
                     LockID             => 123,
                     Queue              => 'some queue',
                     QueueID            => 123,
                     CustomerID         => 'customer_id_123',
                     CustomerUserID     => 'customer_user_id_123',
                     Owner              => 'some_owner_login',
                     OwnerID            => 123,
                     Type               => 'some ticket type',
                     TypeID             => 123,
                     SLA                => 'some sla',
                     SLAID              => 123,
                     Service            => 'some service',
                     ServiceID          => 123,
                     Responsible        => 'some_responsible_login',
                     ResponsibleID      => 123,
                     Age                => 3456,
                     Created            => '2010-10-27 20:15:00',
                     CreateBy           => 123,
                     Changed            => '2010-10-27 20:15:15',
                     ChangeBy           => 123,
                     ArchiveFlag        => 'y',
 
                     DynamicField => [
                         {
                             Name  => 'some name',
                             Value => 'some value',
                         },
                     ],
 
                     # (time stamps of expected escalations)
                     EscalationResponseTime           (unix time stamp of response time escalation)
                     EscalationUpdateTime             (unix time stamp of update time escalation)
                     EscalationSolutionTime           (unix time stamp of solution time escalation)
 
                     # (general escalation info of nearest escalation type)
                     EscalationDestinationIn          (escalation in e. g. 1h 4m)
                     EscalationDestinationTime        (date of escalation in unix time, e. g. 72193292)
                     EscalationDestinationDate        (date of escalation, e. g. "2009-02-14 18:00:00")
                     EscalationTimeWorkingTime        (seconds of working/service time till escalation, e. g. "1800")
                     EscalationTime                   (seconds total till escalation of nearest escalation time type - response, update or solution time, e. g. "3600")
 
                     # (detailed escalation info about first response, update and solution time)
                     FirstResponseTimeEscalation      (if true, ticket is escalated)
                     FirstResponseTimeNotification    (if true, notify - x% of escalation has reached)
                     FirstResponseTimeDestinationTime (date of escalation in unix time, e. g. 72193292)
                     FirstResponseTimeDestinationDate (date of escalation, e. g. "2009-02-14 18:00:00")
                     FirstResponseTimeWorkingTime     (seconds of working/service time till escalation, e. g. "1800")
                     FirstResponseTime                (seconds total till escalation, e. g. "3600")
 
                     UpdateTimeEscalation             (if true, ticket is escalated)
                     UpdateTimeNotification           (if true, notify - x% of escalation has reached)
                     UpdateTimeDestinationTime        (date of escalation in unix time, e. g. 72193292)
                     UpdateTimeDestinationDate        (date of escalation, e. g. "2009-02-14 18:00:00")
                     UpdateTimeWorkingTime            (seconds of working/service time till escalation, e. g. "1800")
                     UpdateTime                       (seconds total till escalation, e. g. "3600")
 
                     SolutionTimeEscalation           (if true, ticket is escalated)
                     SolutionTimeNotification         (if true, notify - x% of escalation has reached)
                     SolutionTimeDestinationTime      (date of escalation in unix time, e. g. 72193292)
                     SolutionTimeDestinationDate      (date of escalation, e. g. "2009-02-14 18:00:00")
                     SolutionTimeWorkingTime          (seconds of working/service time till escalation, e. g. "1800")
                     SolutionTime                     (seconds total till escalation, e. g. "3600")
 
                     Article => [
                         {
                             ArticleID
                             From
                             To
                             Cc
                             Subject
                             Body
                             ReplyTo
                             MessageID
                             InReplyTo
                             References
                             SenderType
                             SenderTypeID
                             CommunicationChannelID
                             IsVisibleForCustomer
                             ContentType
                             Charset
                             MimeType
                             IncomingTime
 
                             DynamicField => [
                                 {
                                     Name  => 'some name',
                                     Value => 'some value',
                                 },
                             ],
 
                             Attachment => [
                                 {
                                     Content            => "xxxx",     # actual attachment contents, base64 encoded
                                     ContentAlternative => "",
                                     ContentID          => "",
                                     ContentType        => "application/pdf",
                                     Filename           => "StdAttachment-Test1.pdf",
                                     Filesize           => "4.6 KBytes",
                                     FilesizeRaw        => 4722,
                                 },
                             ],
                         },
                     ],
                 },
             ],
         },
     };



_CheckTicket()
==============


checks if the given ticket parameters are valid.


.. code-block:: perl

     my $TicketCheck = $OperationObject->_CheckTicket(
         Ticket => $Ticket,                          # all ticket parameters
     );
 
     returns:
 
     $TicketCheck = {
         Success => 1,                               # if everything is OK
     }
 
     $TicketCheck = {
         ErrorCode    => 'Function.Error',           # if error
         ErrorMessage => 'Error description',
     }



_CheckArticle()
===============


checks if the given article parameter is valid.


.. code-block:: perl

     my $ArticleCheck = $OperationObject->_CheckArticle(
         Article => $Article,                        # all article parameters
     );
 
     returns:
 
     $ArticleCheck = {
         Success => 1,                               # if everything is OK
     }
 
     $ArticleCheck = {
         ErrorCode    => 'Function.Error',           # if error
         ErrorMessage => 'Error description',
     }



_CheckDynamicField()
====================


checks if the given dynamic field parameter is valid.


.. code-block:: perl

     my $DynamicFieldCheck = $OperationObject->_CheckDynamicField(
         DynamicField => $DynamicField,              # all dynamic field parameters
     );
 
     returns:
 
     $DynamicFieldCheck = {
         Success => 1,                               # if everything is OK
     }
 
     $DynamicFieldCheck = {
         ErrorCode    => 'Function.Error',           # if error
         ErrorMessage => 'Error description',
     }



_CheckAttachment()
==================


checks if the given attachment parameter is valid.


.. code-block:: perl

     my $AttachmentCheck = $OperationObject->_CheckAttachment(
         Attachment => $Attachment,                  # all attachment parameters
     );
 
     returns:
 
     $AttachmentCheck = {
         Success => 1,                               # if everything is OK
     }
 
     $AttachmentCheck = {
         ErrorCode    => 'Function.Error',           # if error
         ErrorMessage => 'Error description',
     }



_TicketCreate()
===============


creates a ticket with its article and sets dynamic fields and attachments if specified.


.. code-block:: perl

     my $Response = $OperationObject->_TicketCreate(
         Ticket       => $Ticket,                  # all ticket parameters
         Article      => \@Article,                # all article parameters
         DynamicField => $DynamicField,            # all dynamic field parameters
         Attachment   => $Attachment,             # all attachment parameters
         UserID       => 123,
     );
 
     returns:
 
     $Response = {
         Success => 1,                               # if everything was OK
         Data => {
             TicketID     => 123,
             TicketNumber => 'TN3422332',
             ArticleID    => 123,
         }
     }
 
     $Response = {
         Success      => 0,                         # if unexpected error
         ErrorMessage => "$Param{ErrorCode}: $Param{ErrorMessage}",
     }





