<?php
namespace App\Worldspan\LineParser\Types\Line;

/**
 *
 * @author Lucian Sirbu
 */
class DashS extends \App\Worldspan\LineParser\Types\WorldspanBaseLine
{
	protected $extractRegexp = "/^(?P<rawData>-S.+)/sm";

	protected $children = [
        /**
         * The new -S (dash S) record contains the information for each SSRASVC item and for each SVC segment that is found in the PNR and will be sent in the TAIR message
         *   on interface level 20 and higher (see Note 10 and 12)
         * The -S record (or the Services record) contains the information found in the PNR for each SSRASVC and for each SVC segment
         * The information sent in the -S Record can include data such as the passenger name, the date, the amount (if available) and the EMD number (if it has already been
         *   issued)
         */

        ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> '-S\\',               'req'=> true,],              // Record Identifier (see Note 1 and 8 and 9)

        ['key'=> 'complex:3',                                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'SN-',                'req'=> true,],              // Segment Number Identifier
            ['key'=> 'SegmentNumberFromThePNR',                          'type'=> 'Integer',                          'len'=> [1, 3],                                        'req'=> false,],             // Segment number from the PNR
		]],
        ['key'=> '#022',                                             'type'=> 'Separator',                                                                                    'req'=> false,],             // Field Separator

        ['key'=> 'complex:5',                                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'TS-',                'req'=> true,],              // Type of Service Identifier (see Note 2)
            ['key'=> 'TypeOfService',                                    'type'=> 'StringDelimitedByChar',            'len'=> [0, 6],          'val'=> '\\',                 'req'=> true,],             // Type of Service
            ['key'=> '#0xx',                                             'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:7',                                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'BI-',                'req'=> true,],              // Booking Indicator Identifier (see Note 3)
            ['key'=> 'BookingIndicator',                                 'type'=> 'StringDelimitedByChar',            'len'=> [0, 2],          'val'=> '\\',                 'req'=> true,],             // Booking Indicator
            ['key'=> '#0xx',                                             'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:9',                         'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                               'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'NN-',                'req'=> true,],              // Name Number Identifier
            ['key'=> 'SurnameNumber',                     'type'=> 'Integer',                                                                                      'req'=> true,],              // Surname number
            ['key'=> 'key',                               'type'=> 'Constant',                         'len'=> 1,                    'val'=> '.',                  'req'=> true,],              // Item Separator
            ['key'=> 'FirstNameNumber',                   'type'=> 'Integer',                                                                                      'req'=> true,],              // First Name number Level 20 - Interface Message
            ['key'=> '#0xx',                              'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:11',                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                               'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'NM-',                'req'=> true,],              // Passenger Name Identifier
            ['key'=> 'key',                               'type'=> 'StringDelimitedByChar',            'len'=> [0, 2],          'val'=> '\\',                 'req'=> true,],              // Passenger Name
            ['key'=> '#0xx',                              'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:15',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'TO-',                'req'=> true,],              // The TO Identifier
            ['key'=> 'TheTOInformation',                                 'type'=> 'StringDelimitedByChar',            'len'=> 2,                    'val'=> '\\',                 'req'=> true,],              // The TO Information (see Note 4)
            ['key'=> '#0xx',                                             'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:17',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'AT-',                'req'=> true,],              // The AT Identifier
            ['key'=> 'TheATInformation',                                 'type'=> 'StringDelimitedByChar',            'len'=> 3,                    'val'=> '\\',                 'req'=> true,],              // The AT Information (see Note 5)
            ['key'=> '#0xx',                                             'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:19',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'FOR-',               'req'=> true,],              // The FOR Identifier
            ['key'=> 'TheFORData',                                       'type'=> 'StringDelimitedByChar',            'len'=> [0, 34],         'val'=> '\\',                 'req'=> true,],              // The FOR Data (see Note 6)
            ['key'=> '#0xx',                                             'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:21',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'DTE-',               'req'=> true,],              // The Date of Service Identifier
            ['key'=> 'DateOfServiceInformation',                         'type'=> 'StringDelimitedByChar',            'len'=> [0, 9],          'val'=> '\\',                 'req'=> true,],              // Date of Service Information (see Note 7)
            ['key'=> '#0xx',                                             'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

		['key'=> 'complex:13',                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                               'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'ST-',                'req'=> true,],              // Reason for Issuance Code Identifier
            ['key'=> 'TheSegmentStatusCodeAndQuantityOfServices','type'=> 'StringDelimitedByChar',     'len'=> 1,                    'val'=> '\\',                 'req'=> true,],              // Reason for Issuance Code
            ['key'=> '#0xx',                              'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],


		['key'=> 'complex:13',                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                               'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'RFI-',               'req'=> true,],              // Reason for Issuance Code Identifier
            ['key'=> 'ReasonForIssuanceCode',             'type'=> 'StringDelimitedByChar',            'len'=> 1,                    'val'=> '\\',                 'req'=> true,],              // Reason for Issuance Code
            ['key'=> '#0xx',                              'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:25',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'RFC-',               'req'=> true,],              // The RFISC Identifier
            ['key'=> 'ReasonForIssuanceSubCodeItem',                     'type'=> 'StringDelimitedByChar',            'len'=> [0, 3],          'val'=> '\\',                 'req'=> true,],              // Reason for Issuance Sub-Code Item
            ['key'=> '#0xx',                                             'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:27',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'AMT-',               'req'=> true,],              // Amount Identifier
            ['key'=> 'AmountCurrencyCode',                               'type'=> 'Currency',                                                                                     'req'=> true,],              // Amount currency code
            ['key'=> 'AmountInformation',                                'type'=> 'FloatRaw',                                                          'val'=> '\\',                 'req'=> true,],              // Amount information
            ['key'=> '#0xx',                                             'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:29',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'TX-',                'req'=> true,],              // Tax Identifier
            ['key'=> 'TaxCode',                                          'type'=> 'StringRaw',                           'len'=> 2,                    'val'=> '\\',                 'req'=> true,],              // Tax code
            ['key'=> 'TaxAmount',                                        'type'=> 'FloatRaw',                                                                                        'req'=> true,],              // Tax amount
            ['key'=> '#0xx',                                             'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:31',                                       'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                                              'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'TL-',                'req'=> true,],              // Total Identifier
            ['key'=> 'TotalCurrencyCode',                                'type'=> 'Currency',                                                                                     'req'=> true,],              // Total currency code
            ['key'=> 'TotalAmount',                                      'type'=> 'FloatRaw',                                                                                        'req'=> true,],              // Total amount
            ['key'=> '#0xx',                                             'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],

        ['key'=> 'complex:19',                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                               'type'=> 'Constant',                         'len'=> 4,                    'val'=> 'EMD-',               'req'=> true,],              // EMD Number Identifier
            ['key'=> 'EMDNumber',                         'type'=> 'Alphanumeric',                                                                                 'req'=> true,],              // EMD Number
            ['key'=> 'complex:19.1',                       'type'=> 'Complex', 'merge'=>true,                                                                      'req'=> false, 'children'=> [
	            ['key'=> 'key',                               'type'=> 'Constant',                         'len'=> 1,                    'val'=> '-',                  'req'=> true,],             // Dash
	            ['key'=> 'Last3DigitsOfConjunctEMDNumberSet', 'type'=> 'Digits',                                                                                       'req'=> true,],             // Last 3 digits of conjunct EMD number set
			]],
        	['key'=> '#0xx',                              'type'=> 'Constant',                                                       'val'=> '\\',                 'req'=> false,],
		]],


		['key'=> 'complex:19',                        'type'=> 'Complex', 'merge'=>true,                                                                       'req'=> false, 'children'=> [
            ['key'=> 'key',                               'type'=> 'Constant',                         'len'=> 3,                    'val'=> 'FT-',               'req'=> true,],              // EMD Number Identifier
            ['key'=> 'FreeTextData',                      'type'=> 'StringRaw',                                                                                       'req'=> true,],              // EMD Number
		]],
	];
}
