@extends('backend.partials.master') @section('title', ___('menus.flight_api')) @section('maincontent') @php // One section per driver in App\Services\FlightSearchService::PROVIDERS. // Field: [setting key, label key, type (text|secret|url), placeholder key or URL default]. $flightSearch = app(\App\Services\FlightSearchService::class); $providers = $flightSearch->providers(); $enabled = old('flight_providers_enabled', $flightSearch->enabledKeys()); $keyHint = ___('admin.leave_blank_to_keep_saved_key_7e43b6'); $secretHint = ___('admin.leave_blank_to_keep_saved_secret_1d2ccf'); $passwordHint = ___('admin.leave_blank_to_keep_saved_password_30dc98'); $tokenHint = ___('admin.leave_blank_to_keep_saved_token_f1b451'); $sections = [ 'amadeus' => [ 'title' => ___('admin.amadeus_flight_api_43143a'), 'help' => ___('admin.used_for_live_flight_offer_search_and_with_the_same_cre_a46f7b') . ' & ' . ___('admin.booking_credentials_are_encrypted_leave_secret_fields_b_174e3c'), 'fields' => [ ['amadeus_api_key', ___('admin.amadeus_api_key_697c89'), 'secret', $keyHint], ['amadeus_api_secret', ___('admin.amadeus_secret_705207'), 'secret', $secretHint], ['amadeus_api_url', ___('admin.amadeus_url_c31c1f'), 'url', 'https://test.api.amadeus.com'], ], ], 'sabre' => [ 'title' => ___('admin.sabre_bargain_finder_max_049f92'), 'help' => ___('admin.sabre_help_87f611'), 'fields' => [ ['sabre_client_id', ___('admin.client_id_352737'), 'text', 'V1:EPR:PCC:AA'], ['sabre_client_secret', ___('admin.client_secret_0ea717'), 'secret', $secretHint], ['sabre_pcc', ___('admin.pseudo_city_code_pcc_08cedd'), 'text', ''], ['sabre_api_url', ___('admin.api_base_url_93efe7'), 'url', 'https://api.cert.platform.sabre.com'], ], ], 'travelport' => [ 'title' => ___('admin.travelport_json_air_api_95ee7b'), 'help' => ___('admin.travelport_help_f453a4'), 'fields' => [ ['travelport_username', ___('admin.username_1f231e'), 'text', ''], ['travelport_password', ___('admin.password_f7f01d'), 'secret', $passwordHint], ['travelport_access_group', ___('admin.access_group_target_branch_746d95'), 'text', ''], ['travelport_client_id', ___('admin.client_id_352737'), 'text', ''], ['travelport_client_secret', ___('admin.client_secret_0ea717'), 'secret', $secretHint], ['travelport_oauth_url', ___('admin.oauth_token_url_2353f1'), 'url', 'https://oauth.pp.travelport.com/oauthahs/oauth2/token'], ['travelport_api_url', ___('admin.api_base_url_93efe7'), 'url', 'https://api.pp.travelport.com/11/air'], ], ], 'duffel' => [ 'title' => ___('admin.duffel_1e344a'), 'help' => ___('admin.duffel_help_a98761'), 'fields' => [ ['duffel_access_token', ___('admin.access_token_f69d5c'), 'secret', $tokenHint], ['duffel_api_url', ___('admin.api_base_url_93efe7'), 'url', 'https://api.duffel.com'], ], ], 'tbo' => [ 'title' => ___('admin.tbo_air_tek_travels_e788db'), 'help' => ___('admin.tbo_help_302495'), 'fields' => [ ['tbo_client_id', ___('admin.client_id_352737'), 'text', 'ApiIntegrationNew'], ['tbo_username', ___('admin.username_1f231e'), 'text', ''], ['tbo_password', ___('admin.password_f7f01d'), 'secret', $passwordHint], ['tbo_auth_url', ___('admin.authenticate_url_68e8fd'), 'url', 'http://api.tektravels.com/SharedServices/SharedData.svc/rest/Authenticate'], ['tbo_search_url', ___('admin.search_url_237f23'), 'url', 'http://api.tektravels.com/BookingEngineService_Air/AirService.svc/rest/Search'], ], ], 'kiwi' => [ 'title' => ___('admin.kiwi_tequila_098530'), 'help' => ___('admin.kiwi_help_efc3d0'), 'fields' => [ ['kiwi_api_key', ___('admin.api_key_4792d2'), 'secret', $keyHint], ['kiwi_api_url', ___('admin.api_base_url_93efe7'), 'url', 'https://api.tequila.kiwi.com'], ], ], ]; // Providers are shown in two groups: classic GDS contracts and API-key // aggregators. Any provider not listed here falls into the last group. $groups = [ 'gds' => ['title' => ___('admin.flight_group_gds_title'), 'help' => ___('admin.flight_group_gds_help'), 'icon' => 'fa-solid fa-globe', 'keys' => ['amadeus', 'sabre', 'travelport']], 'ndc' => ['title' => ___('admin.flight_group_ndc_title'), 'help' => ___('admin.flight_group_ndc_help'), 'icon' => 'fa-solid fa-plug', 'keys' => ['duffel', 'tbo', 'kiwi']], ]; $groups['ndc']['keys'] = array_values(array_diff(array_keys($sections), $groups['gds']['keys'])); $statusLabels = [ 'live' => ___('admin.flight_status_live'), 'missing' => ___('admin.flight_status_missing'), 'off' => ___('admin.configured_f6ccf7'), 'none' => ___('admin.not_configured_ff9683'), ]; $visible = array_intersect_key($sections, $providers); $configuredCount = count(array_filter(array_keys($visible), fn ($key) => $providers[$key]->isConfigured())); $liveCount = count(array_filter(array_keys($visible), fn ($key) => $providers[$key]->isConfigured() && in_array($key, (array) $enabled, true))); @endphp

{{ ___('menus.flight_api') }}

@csrf @method('PUT') {{-- Always posted, so un-ticking every provider still saves as "none". --}}
{{ ___('admin.live_flight_providers_405b71') }}

{{ ___('admin.flight_providers_intro_0843fc') }}

{{ count($visible) }}{{ ___('admin.flight_summary_providers') }}
{{ $configuredCount }}{{ ___('admin.configured_f6ccf7') }}
{{ $liveCount }}{{ ___('admin.flight_summary_live') }}
@foreach($groups as $groupKey => $group) @php $groupKeys = array_values(array_filter($group['keys'], fn ($key) => isset($visible[$key]))); @endphp @continue(empty($groupKeys))
{{ $group['title'] }}

{{ $group['help'] }}

{{ count($groupKeys) }}
@foreach($groupKeys as $key) @php $section = $sections[$key]; $configured = $providers[$key]->isConfigured(); $isOn = in_array($key, (array) $enabled, true); $fieldNames = array_column($section['fields'], 0); $hasError = collect($fieldNames)->contains(fn ($name) => $errors->has($name)); $credentials = array_values(array_filter($section['fields'], fn ($field) => $field[2] !== 'url')); $endpoints = array_values(array_filter($section['fields'], fn ($field) => $field[2] === 'url')); $open = $hasError || $isOn; @endphp
@endforeach
@endforeach @if(hasPermission('general_settings_update'))
@endif
@endsection