Auth->Login("your@email.com", "your_password"); // var_dump($a->Articles->GetArticles()); require_once 'HTTP/Request2.php'; // Only when installed with PEAR /**************************************************** * Enumerations used by the API * ****************************************************/ enum DTO_BillStatus: int { case Open = 1; case Paid = 2; case Canceled = 3; case Replaced = 4; case Current = 5; case Draft = 10; } enum DTO_AircraftType: int { case Glider = 1; case PoweredGlider = 2; case Airplane = 3; case Balloon = 4; case Helicopter = 5; case Gyrocopter = 6; case Airship = 7; } enum DTO_FlightLogTypes: int { case Departure = 1; case Arrival = 2; case Circuits = 3; case ExternalArrival = 4; case ExternalDeparture = 5; } enum DTO_UnitTypes: int { case Single = 1; case Minutes = 2; case Litters = 3; } enum DTO_ArticleType: int { case Membership = 1; case FuelSale = 2; case Instruction = 3; case AircraftRentPricing = 4; case AircraftLandingPricing = 5; case AircraftStartPricing = 6; case FuelReimbursement = 7; case Towing = 8; case Facility = 9; case PaperBill = 10; case TrialFlight = 11; case FirstReminder = 51; case SecondReminder = 52; case ThirdReminder = 53; case Rounding = 80; case Other = 100; } enum DTO_AccountType: int { case Debitor = 1; case Account = 2; case MeansOfPayment = 3; case TransferAccount = 4; case RoundingDifference = 5; } enum DTO_InstructionState: int { case Filled = 1; case Accepted = 2; case Refused = 3; } enum DTO_NewsVisibility: int { case Outside = 1; case Inside = 2; case Both = 3; case Calendar = 4; case WelcomeEmail = 5; case Home = 6; case OPS = 7; case Events = 8; case Billing = 9; case AircraftCategory = 10; case Aircraft = 11; } enum DTO_TechLogStatus: int { case Close = 1; case CRS = 2; case CRS_Check = 3; case DD_NotFlightRelevant = 4; case DD_Restriction = 5; case ForInformationOnly = 6; case NotAirworthy = 7; case NotFlightRelevant = 8; case FlightRelevant_AOG = 9; case ARC = 10; } enum DTO_ExternalTool: int { case NoExternalTool = 1; case Vereinsflieger = 2; } enum DTO_Recuring: int { case NotRecuring = 0; case Annually = 1; case Monthly = 2; case Weekly = 3; } enum DTO_ComponentCycle: int { case Hours = 1; case Date = 2; } enum DTO_ActionType: int { case Register = 0; case Login = 1; case Logout = 2; case InvalidCaptcha = 3; case AdminResetPassword = 4; case AdminSetPassword = 5; case AdminModifyProfile = 6; case AdminCreateReservationType = 7; case AdminDeleteReservationType = 8; case AdminEditReservationType = 9; case AdminDeleteAircraft = 10; case AdminDeleteMember = 11; case AdminCreateAircraft = 12; case AdminEditAircraft = 13; case AdminCreateNews = 14; case AdminEditNews = 15; case AdminDeleteNews = 16; case AdminDeleteArticle = 17; case AdminCreateArticle = 18; case AdminEditArticle = 19; case AdminCreateAircraftArticle = 20; case AdminEditAircraftArticle = 21; case AdminDeleteAircraftArticle = 22; case AdminDeleteTechlog = 23; case AdminCreateTechlog = 24; case AdminUpdateTechlog = 25; case CreateReservation = 26; case UpdateReservation = 27; case DeleteReservation = 28; case CreateMovement = 29; case AdminCreateAircraftModel = 30; case AdminEditAircraftModel = 31; case AdminDeleteAircraftModel = 32; case AdminRemoveMembership = 33; case AdminAddMembership = 34; case AdminRefuseCounterCorrection = 35; case CreateInstruction = 36; case InstructionAccepted = 37; case InstructionRefused = 38; case MinutesFlown = 39; case InstructionTime = 40; case Landing = 41; case GoArround = 42; case AdminAddMember = 43; case AdminEditMember = 44; case UpdateInstruction = 45; case ChangedPassword = 46; case EditProfile = 47; case AdminDeleteVatAccount = 48; case AdminCreateVatAccount = 49; case AdminEditVatAccount = 50; case AdminDeleteVatType = 51; case AdminCreateVatType = 52; case AdminEditVatType = 53; case AdminDeleteAccountPlan = 54; case AdminCreateAccountPlan = 55; case AdminEditAccountPlan = 56; case AdminDeleteCatalog = 57; case AdminEditCatalog = 58; case AdminCreateCatalog = 59; case AdminDeleteFlightActivityType = 60; case AdminCreateFlightActivityType = 61; case AdminEditFlightActivityType = 62; case AdminDeleteInstructionType = 63; case AdminCreateInstructionType = 64; case AdminEditInstructionType = 65; case AdminAddRole = 66; case AdminRemoveRole = 67; case AdminDeleteRoleType = 68; case AdminCreateRoleType = 69; case AdminEditRoleType = 70; case AdminCreateMembershipType = 71; case AdminEditMembershipType = 72; case AdminDeleteMembershipType = 73; case AdminDeleteAllMemberships = 74; case AdminCreateTransaction = 75; case AdminAddFlightActivityTypeAccountPlan = 76; case AdminDeleteFlightActivityTypeAccountPlan = 77; case AdminCopyFlightActivityTypeAccountPlan = 78; case AdminAddFlightActivityAircraftType = 79; case AdminDeleteFlightActivityAircraftType = 80; case AdminAddFlightActivityRole = 81; case AdminDeleteFlightActivityRole = 82; case AdminAddAircraftActivityType = 83; case AdminDeleteAircraftActivityType = 84; case AdminCreateShopArticle = 85; case AdminEditShopArticle = 86; case AdminDeleteShopArticle = 87; case AdminRemoveShopArticleRequirement = 88; case AdminAddShopArticleRequirement = 89; case AdminDeleteAircraftCategory = 90; case AdminCreateAircraftCategory = 91; case AdminEditAircraftCategory = 92; case AdminRemoveUserAircraftCategory = 93; case AdminAddUserAircraftCategory = 94; case AdminCreateMember = 95; case AcceptPrivacy = 96; case AdminCreateLink = 97; case AdminEditLink = 98; case AdminDeleteLink = 99; case AdminRemoveAttachementsNews = 100; case AdminDeleteCompany = 101; case AdminCreateCompany = 102; case AdminEditCompany = 103; case AdminDeleteStockItem = 104; case AdminCreateStockItem = 105; case AdminEditStockItem = 106; case AdminImportStockItems = 107; case CamoAddAircraftComponent = 108; case EditNotifications = 109; case CreateAircraftLog = 110; case CreateTechlog = 111; case AdminDeleteCostUnit = 112; case AdminCreateCostUnit = 113; case AdminEditCostUnit = 114; case AdminDeleteCostCenter = 115; case AdminCreateCostCenter = 116; case AdminEditCostCenter = 117; case AdminCopyFromFlightActivityTypeAccountPlan = 118; case AdminDeleteBill = 119; case AdminCreateBill = 120; case AdminAddTransaction = 121; case AdminRemoveTransaction = 122; case AdminBillMarkedAsPaid = 123; case AdminBillMarkedCanceled = 124; case AdminBillReplaced = 125; case AdminBillFinalized = 126; case AdminBillSent = 127; case AdminBillingSent = 128; case AdminRemindersSent = 129; case AdminImportFinancialConfig = 130; case AdminDeletePriceValidity = 131; case AdminCreatePriceValidity = 132; case AdminEditPriceValidity = 133; case ModifyMovement = 134; case AdminDeleteRunway = 135; case AdminCreateRunway = 136; case AdminEditRunway = 137; case AdminDeleteArrivalSector = 138; case AdminCreateArrivalSector = 139; case AdminEditArrivalSector = 140; case AdminDeleteDepartureRoute = 141; case AdminCreateDepartureRoute = 142; case AdminEditDepartureRoute = 143; case AdminDeleteHoliday = 144; case AdminCreateHoliday = 145; case AdminEditHoliday = 146; case AdminDeleteRegistrationRequest = 147; case AdminCreateRegistrationRequest = 148; case AdminEditRegistrationRequest = 149; case AddMemberCredits = 150; case AdminBillReOpened = 151; case OnlinePurchase = 152; case DeleteMovement = 153; case AdminAddMemberVatAccountLink = 154; case AdminRemoveMemberVatAccountLink = 155; case AdminAddAircraftModel = 156; case AdminAddAircraft = 157; case AdminSetGlobalCss = 158; case AdminSetPrivateCss = 159; case AdminRemovedGlobalCss = 160; case AdminRemovedPrivateCss = 161; case AdminAddArticleAircraftType = 162; case AdminRemoveArticleAircraftType = 163; case AdminAddArticleAircraftCategory = 164; case AdminRemoveArticleAircraftCategory = 165; } enum DTO_MemberDefaultType: int { case ReservationType = 1; case InstructorId = 2; case LastMovementCallSign = 3; case ReservationInstructor = 4; case LastInstructionType = 5; case LastFlightActivityType = 6; case CalendarReminder = 7; case ExportRoles = 8; case ExportMemberships = 9; case PlannedTime = 10; } enum DTO_NotificationCategory: int { case System = 0; case ChangeReservation = 1; case NewBilling = 2; case NewInstruction = 3; case Newsletter = 4; case NewReservation = 5; case CancelReservation = 6; case Maintenance = 7; case Instructors = 8; case Accounting = 9; } enum DTO_MembershipValidity: int { case Forever = 1; case Yearly = 2; case Monthly = 3; case CalendarYear = 4; case TillSpecified = 5; } enum DTO_MembershipType: int { case Generic = 1; case Aircraft = 2; } enum DTO_PreferredForAircraftType: int { case All = 0; case Motor = 1; case Glider = 2; } enum DTO_DocumentFor: int { case FlightLogCounterCorrection = 1; case FlightLogFuel = 2; case News = 3; } /**************************************************** * DTOs used by the API * ****************************************************/ /** * @property string $url * @property string $title * @property string $when * @property int $nbMinutes * @property string $details */ interface DTO_VisitedPage { } /** * @property int $id * @property int $flightActivityTypeId * @property int $aircraftId * @property ?int $startCounter * @property ?int $endCounter * @property int $memberId * @property ?int $instructorId * @property ?string $departureTime * @property string $startPlace * @property ?string $arrivalTime * @property string $landingPlace * @property ?int $nbLandings * @property ?float $fuelLitters * @property string $callSign * @property string $flightActivityType * @property string $member */ interface DTO_AircraftLog { } /** * @property int $id * @property string $icaoType * @property string $manufacturer * @property string $modelType * @property string $marketingDesignation * @property DTO_Aircraft[] $aircrafts * @property string $displayName */ interface DTO_AircraftModel { } /** * @property int $id * @property string $callSign * @property string $display * @property bool $visible * @property int $order * @property DTO_AircraftType $aircraftType * @property ?bool $inCAMO * @property ?bool $canBeBooked * @property string $timeCounter * @property ?int $modelId * @property ?int $nextControl * @property string $nextControlTimer * @property ?bool $homeBase * @property ?int $landingCounter * @property string $mainOwner * @property ?int $mainMemberId * @property ?string $nextAnnual * @property ?string $nextArcReview * @property ?string $nextArcExtension * @property ?int $aircraftCategoryId * @property ?DTO_FlightLogTypes $lastLogType * @property string $lastAirport * @property DTO_FlightActivityType[] $allowedActivities * @property string $expectedDestination * @property ?bool $isValid */ interface DTO_Aircraft { } /** * @property string $callSign * @property ?int $timeCounter * @property string $remaining * @property ?int $landingCounter * @property ?int $nextControl * @property ?int $nextControlTimer * @property ?string $nextAnnual * @property ?string $nextArcReview * @property ?string $nextArcExtension */ interface DTO_AircraftCAMO { } /** * @property int $id * @property string $name * @property string $description * @property ?int $nbPlaces * @property ?bool $isActive */ interface DTO_AircraftCategory { } /** * @property int $id * @property string $name */ interface DTO_IdName { } /** * @property string $icao * @property string $name * @property string $display */ interface DTO_Airport { } /** * @property int $id * @property int $catalogId * @property string $description * @property string $display * @property float $pricePerUnit * @property DTO_UnitTypes $unit * @property ?bool $isValid * @property DTO_ArticleType $articleType * @property ?int $aircraftCategoryId * @property ?int $membershipId * @property ?int $requiredAdditionalMembershipId * @property ?int $supersedeId * @property ?int $accountPlanId * @property ?int $vatTypeId * @property ?int $fuelCardArticleId * @property ?int $costCenterId * @property ?int $costUnitId * @property string $importId */ interface DTO_Article { } /** * @property int $id * @property int $articleId * @property float $pricePerUnit * @property ?int $aircraftCategoryId * @property ?int $membershipId * @property ?int $aircraftWeightCategoryId * @property ?int $aircraftNoiseCategoryId * @property ?int $priceValidityId */ interface DTO_ArticlePrice { } /** * @property string $name * @property string $size * @property string $date */ interface DTO_DocumentInfo { } /** * @property DTO_Aircraft[] $aircrafts * @property DTO_CalendarReservation[] $reservations * @property string $start * @property string $end * @property DTO_ReservationType[] $reservationTypes * @property int $weekNumber * @property DTO_CalendarReservation[] $ownEntries * @property DTO_WeatherForecast[] $weather * @property int $sunRise * @property int $sunSet * @property DTO_AircraftLog[] $aircraftLogs * @property DTO_CalendarHoliday[] $holidays */ interface DTO_CalendarData { } /** * @property int $id * @property string $name * @property ?string $validFrom * @property ?string $validTo * @property ?bool $isActive */ interface DTO_Catalog { } /** * @property string $shortName * @property string $name * @property string $display */ interface DTO_Currency { } /** * @property float $cpuLoad * @property float $swapLoad * @property float $memoryLoad */ interface DTO_DiagnosticInfo { } /** * @property string $filename * @property string $path */ interface DTO_Document { } /** * @property int $id * @property string $company * @property string $title * @property string $firstName * @property string $lastName * @property string $address * @property string $zipCode * @property string $city * @property string $country * @property string $accountNumber * @property string $referenceNumber * @property string $vatNumber * @property string $email * @property string $phoneNumber * @property string $bankName * @property string $bankLocation * @property ?int $importId * @property ?string $validFrom * @property ?string $validTill * @property ?int $mainDebtorId * @property ?int $paymentTerms */ interface DTO_VatAccount { } /** * @property int $id * @property string $name * @property string $accountNumber * @property DTO_AccountType $accountType * @property ?int $importId * @property int $vatAccountId */ interface DTO_AccountPlan { } /** * @property int $id * @property string $shortName * @property string $name * @property string $accountNumber * @property float $amount * @property int $vatAccountId * @property ?int $importId */ interface DTO_VatType { } /** * @property int $id * @property string $name * @property ?bool $requiresInstructor * @property ?bool $isTowing */ interface DTO_FlightActivityType { } /** * @property string $lastEntry * @property int $lastEntryId * @property int $nbEntries */ interface DTO_TableStat { } /** * @property int $id * @property int $instructorId * @property int $studentId * @property string $startDate * @property string $endDate * @property int $nbMinutes * @property DTO_InstructionState $state * @property string $comment * @property int $instructionTypeId */ interface DTO_Instruction { } /** * @property int $id * @property string $name * @property int $displayOrder * @property string $url */ interface DTO_HomeLink { } /** * @property int $memberId * @property int $membershipId * @property string $createdOn * @property string $validTill */ interface DTO_MemberMembership { } /** * @property int $id * @property string $company * @property string $title * @property string $fullName * @property string $email * @property string $display * @property string $firstName * @property string $lastName * @property string $password * @property string $address * @property string $phone * @property string $importFrom * @property string $importId * @property string $emergencyContact * @property ?string $birthday * @property ?string $lastBooking * @property string $zipCode * @property string $city * @property string $country * @property ?int $caution * @property bool $canLog * @property ?bool $verified * @property string $licenseNumber * @property ?string $ratingValidTill * @property ?string $medicalValidTill * @property ?string $languageValidTill * @property ?string $fiCriValidTill * @property ?string $refreshFlightDue * @property ?string $tmgValidTill */ interface DTO_Member { } /** * @property int $id * @property int $memberId * @property int $writtenById * @property string $writtenBy * @property string $storedWhen * @property string $content */ interface DTO_MemberHistory { } /** * @property int $id * @property DTO_FlightLogTypes $logType * @property int $flightActivityTypeId * @property string $callSign * @property ?int $aircraftId * @property string $guestPilot * @property ?int $memberId * @property ?int $instructorId * @property ?string $departureTime * @property string $startPlace * @property ?string $arrivalTime * @property string $landingPlace * @property ?int $nbLandings * @property ?int $goArrounds * @property ?int $runwayId * @property ?int $arrivalSectorId * @property ?int $departureRouteId * @property string $requestedTowingJob * @property string $hiddenTowingJob * @property ?bool $externalTowingPaid * @property string $pilot */ interface DTO_FlightLog { } /** * @property int $id * @property string $title * @property string $content * @property string $postedOn * @property ?int $postedById * @property DTO_NewsVisibility $visibility */ interface DTO_News { } /** * @property int $id * @property string $start * @property string $end * @property int $aircraftId * @property ?bool $isStandby * @property ?bool $isProvisory * @property ?bool $isDeleted * @property int $reservationTypeId * @property int $memberId * @property ?int $instructorId * @property string $comment * @property ?int $plannedTime * @property ?string $aircraftAcceptedOn * @property ?string $aircraftReturnedOn */ interface DTO_Reservation { } /** * @property int $id * @property string $name * @property int $priority * @property ?bool $canDoubleBook * @property ?bool $requiresInstructor * @property ?int $requiredRightTypeId * @property string $cssColor */ interface DTO_ReservationType { } /** * @property string $url * @property string $category * @property string $description */ interface DTO_SearchResult { } /** * @property ?int $nextControl * @property string $hoursRemaining * @property DTO_DisplayTechlogEntry[] $entries * @property ?int $nextControlTimer * @property ?int $timeCounter */ interface DTO_DisplayTechlog { } /** * @property int $id * @property ?int $responseToId * @property ?int $responseById * @property int $aircraftId * @property ?int $flightLogId * @property ?int $reportedMemberId * @property string $entryReport * @property string $entryDate * @property ?int $duplicateOfId * @property DTO_TechLogStatus $status * @property ?int $importId */ interface DTO_TechLog { } /** * @property int $id * @property string $createdWhen * @property ?int $registeredById * @property int $memberId * @property ?int $articleId * @property ?int $aircraftId * @property float $price * @property float $quantity * @property ?int $flightLogId * @property ?int $instructionId * @property ?int $articlePriceId * @property ?int $accountPlanId * @property ?int $vatTypeId * @property ?float $vatAmount * @property ?int $billId * @property ?bool $shouldBeBilled * @property string $importId * @property string $customDescription * @property string $description */ interface DTO_Transaction { } /** * @property int $id * @property string $referenceNumber * @property int $memberId * @property int $vatAccountId * @property float $total * @property ?int $newBillId * @property string $createdOn * @property string $dueOn * @property ?string $paidOn * @property DTO_BillStatus $status * @property ?int $importId */ interface DTO_Bill { } /** * @property int $id * @property string $start * @property string $end * @property string $callSign * @property bool $isStandby * @property bool $isProvisory * @property string $cssColor * @property int $reservationTypeId * @property string $reservationType * @property int $priority * @property string $member * @property string $lastName * @property string $phone * @property int $memberId * @property string $instructor * @property int $instructorId * @property bool $ownReservation * @property bool $canAcceptAircraft * @property bool $canReturnAircraft * @property bool $aircraftAccepted * @property bool $aircraftReturned */ interface DTO_CalendarReservation { } /** * @property string $date * @property string $forecast * @property string $icon */ interface DTO_WeatherForecast { } /** * @property int $id * @property string $name * @property string $date * @property DTO_Recuring $recuring */ interface DTO_CalendarHoliday { } /** * @property string $reportedMember * @property string $entryReport * @property string $entryDate * @property ?string $resolutionTime * @property string $status */ interface DTO_DisplayTechlogEntry { } /** * @property int $id * @property string $accountNumber * @property string $name * @property ?int $appliesToVatAccountId * @property DTO_VatAccount $appliesToVatAccount */ interface DTO_CostUnit { } /** * @property int $aicraftId * @property DTO_Aircraft $aircraft * @property int $flightActivityTypeId * @property DTO_FlightActivityType $flightActivityType */ interface DTO_AllowedFlightActivityType { } /** * @property int $id * @property int $aircraftId * @property DTO_Aircraft $aircraft * @property string $name * @property DTO_ComponentCycle $componentCycle * @property string $current * @property string $warning * @property string $error */ interface DTO_AircraftComponent { } /** * @property int $id * @property int $roleId * @property DTO_RoleType $role * @property int $memberId * @property DTO_Member $member * @property ?int $appliesToVatAccountId * @property DTO_VatAccount $appliesToVatAccount * @property string $allowedExport * @property string $allowedReport */ interface DTO_MemberRole { } /** * @property int $id * @property string $name */ interface DTO_RegistrationRequest { } /** * @property int $id * @property ?int $memberId * @property DTO_Member $member * @property string $ip * @property string $when * @property DTO_ActionType $action * @property string $parameters */ interface DTO_MemberAction { } /** * @property int $memberId * @property DTO_Member $member * @property DTO_MemberDefaultType $defaultType * @property string $value */ interface DTO_MemberDefault { } /** * @property int $memberId * @property DTO_Member $member * @property int $aircraftId * @property DTO_Aircraft $aircraft * @property ?bool $isVisible * @property ?int $order */ interface DTO_MemberCalendarAircraft { } /** * @property int $memberId * @property DTO_Member $member * @property int $aircraftCategoryId * @property DTO_AircraftCategory $aircraftCategory */ interface DTO_MemberAircraftCategory { } /** * @property int $id * @property int $memberId * @property DTO_Member $member * @property string $endPoint * @property string $p256DH * @property string $auth */ interface DTO_MemberWebPush { } /** * @property int $memberId * @property string $url */ interface DTO_MemberBookmark { } /** * @property int $memberId * @property DTO_Member $member * @property DTO_NotificationCategory $category */ interface DTO_MemberNotification { } /** * @property int $memberId * @property DTO_Member $member * @property int $vatAccountId * @property DTO_VatAccount $vatAccount */ interface DTO_MemberVatAccountLink { } /** * @property int $id * @property string $name * @property DTO_MembershipValidity $validity * @property DTO_MembershipType $membershipType * @property ?int $articleId * @property DTO_Article $article * @property DTO_Article[] $requiredBy * @property DTO_Article[] $requiredAdditionallyBy */ interface DTO_Membership { } /** * @property int $id * @property string $accountNumber * @property string $name * @property ?int $appliesToVatAccountId * @property DTO_VatAccount $appliesToVatAccount */ interface DTO_CostCenter { } /** * @property int $articleId * @property DTO_Article $article * @property DTO_AircraftType $aircraftType */ interface DTO_ArticleRequiredAircraftType { } /** * @property int $articleId * @property DTO_Article $article * @property int $aircraftCategoryId * @property DTO_AircraftCategory $aircraftCategory */ interface DTO_ArticleRequiredAircraftCategory { } /** * @property int $id * @property string $name * @property ?int $maxNumberReservations * @property DTO_RoleRight[] $rights */ interface DTO_RoleType { } /** * @property int $id * @property string $name * @property DTO_PreferredForAircraftType $preferredFor * @property string $runwayType */ interface DTO_Runway { } /** * @property int $id * @property string $name * @property DTO_PreferredForAircraftType $preferredFor */ interface DTO_ArrivalSector { } /** * @property int $id * @property string $name * @property DTO_PreferredForAircraftType $preferredFor */ interface DTO_DepartureRoute { } /** * @property int $id * @property DTO_DocumentFor $documentFor * @property ?int $attachedTo * @property string $documentName * @property string $documentType * @property int[] $documentData */ interface DTO_AttachedDocument { } /** * @property int $id * @property string $name * @property string $validFrom * @property ?string $validTo */ interface DTO_PriceValidity { } /** * @property int $id * @property string $name * @property int $mtow * @property ?bool $forFurtherWeightBlocks */ interface DTO_AircraftWeightCategory { } /** * @property int $id * @property string $noiseCategories */ interface DTO_AircraftNoiseCategory { } /** * @property int $flightActivityTypeId * @property DTO_FlightActivityType $flightActivityType * @property int $roleTypeId * @property DTO_RoleType $roleType */ interface DTO_FlightTypeRequiredRole { } /** * @property int $flightActivityTypeId * @property DTO_FlightActivityType $flightActivityType * @property DTO_AircraftType $aircraftType */ interface DTO_FlightTypeRequiredAircraftType { } /** * @property int $accountPlanId * @property DTO_AccountPlan $accountPlan * @property int $flightActivityTypeId * @property DTO_FlightActivityType $flightActivityType * @property int $articleId * @property DTO_Article $article * @property int $vatTypeId * @property DTO_VatType $vatType */ interface DTO_FlightTypeArticleAccountPlan { } /** * @property int $roleTypeId * @property DTO_RoleType $roleType * @property int $rightTypeId * @property DTO_RightType $rightType */ interface DTO_RoleRight { } /** * @property int $id * @property string $name */ interface DTO_RightType { } /** * API For the Action History Menu */ class FlyingFleet_ActionHistory { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } public function GetHistory(string $q = null): ?array { $request = new HTTP_Request2($this->parent->url . "api/ActionHistory/" . urlEncode($q), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Aircraft Log */ class FlyingFleet_AircraftLogs { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of the last 100 movements. * @param ?string $start * @param ?string $end * @return DTO_AircraftLog[] */ public function GetLogs(?string $start = null, ?string $end = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/AircraftLogs?token=" . urlEncode($this->parent->token) . "&start=" . urlEncode($start == null ? "" : json_encode($start)) . "&end=" . urlEncode($end == null ? "" : json_encode($end)) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new aircraft log. * @param DTO_AircraftLog $aircraftLog * @return DTO_AircraftLog */ public function AddAircraftLog($aircraftLog): ?DTO_AircraftLog { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/AircraftLogs?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($aircraftLog)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert new aircraft logs. * @param DTO_AircraftLog[] $aircraftLogs * @return DTO_AircraftLog[] */ public function AddAircraftLogs($aircraftLogs): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/AircraftLogs/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($aircraftLogs)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Aircraft Models */ class FlyingFleet_AircraftModels { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Get the list of all the aircraft models known * @param string $q * @return DTO_AircraftModel[] */ public function GetAircraftModels(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/AircraftModels/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Counts the number of aircraft given the optional search parameter * @param string $q * @return int */ public function GetAircraftModelsCount(string $q = null): ?int { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/AircraftModels/No/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the model information based on the provided id * @param int $id * @return DTO_AircraftModel */ public function GetAircraftModel(int $id): ?DTO_AircraftModel { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/AircraftModels/ById/" . urlEncode($id) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new aircraft model * @param DTO_AircraftModel $model * @return DTO_AircraftModel */ public function AddModel($model): ?DTO_AircraftModel { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/AircraftModels?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($model)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Aircrafts */ class FlyingFleet_Aircrafts { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Get the list of all the aircrafts known * @param string $q * @param bool $onlyCharter * @return DTO_Aircraft[] */ public function GetAircrafts(string $q = null, bool $onlyCharter = False): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&onlyCharter=" . urlEncode($onlyCharter == null ? "" : json_encode($onlyCharter)) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the number of aircrafts given the optional search parameter * @param string $q * @param bool $onlyCharter * @return int */ public function GetAircraftsCount(string $q = null, bool $onlyCharter = False): ?int { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/No/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&onlyCharter=" . urlEncode($onlyCharter == null ? "" : json_encode($onlyCharter)), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get all the aircraft CAMO information */ public function GetAircraftCamos() { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/CAMO?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the aircraft CAMO information based on the provided callsign * @param string $callsign * @return DTO_AircraftCAMO */ public function GetAircraftCamo(string $callsign): ?DTO_AircraftCAMO { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/CAMO/" . urlEncode($callsign) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the aircraft information based on the provided callsign * @param string $callsign * @return DTO_Aircraft */ public function GetAircraftByCallSign(string $callsign): ?DTO_Aircraft { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/ByCallSign/" . urlEncode($callsign) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the aircraft information based on the provided id * @param int $id * @return DTO_Aircraft */ public function GetAircraftById(int $id): ?DTO_Aircraft { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/ById/" . urlEncode($id) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Add a new aircraft * @param DTO_Aircraft $aircraft * @return DTO_Aircraft */ public function UpdateAircraft($aircraft): ?DTO_Aircraft { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($aircraft)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Retrieves the list of the aircrafts that can be rented * @return DTO_Aircraft[] */ public function GetAircraftsToRent(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/ToRent?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Retrieves the list of the id / names of the aircrafts categories * @return DTO_AircraftCategory[] */ public function GetAircraftsCategories(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/Categories?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Retrieves the list of the id / names of the aircrafts memberships * @return DTO_IdName[] */ public function GetAircraftsMemberships(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/Memberships?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Retrieves the list of the id / names of the aircrafts weight categories * @return DTO_IdName[] */ public function GetAircraftsWeightCategories(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/WeightCategories?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Retrieves the list of the id / names of the aircrafts noise categories * @return DTO_IdName[] */ public function GetAircraftsNoiseCategories(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/NoiseCategories?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Set the allowed flight activity types for an aircraft * @param int $aircraftId * @param int[] $allowedActivities * @return bool */ public function SetAllowedFlightActivityTypes($allowedActivities, int $aircraftId): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts/AllowedFlightActivityTypes?token=" . urlEncode($this->parent->token) . "&aircraftId=" . urlEncode($aircraftId == null ? "" : json_encode($aircraftId)), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($allowedActivities)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new aircraft * @param DTO_Aircraft $aircraft * @return DTO_Aircraft */ public function AddAircraft($aircraft): ?DTO_Aircraft { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Aircrafts?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($aircraft)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Airports */ class FlyingFleet_Airports { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Get the list of all the airports known * @param string $q * @return DTO_Airport[] */ public function GetAirports(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Airports/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the number of airports known. * @param string $q * @return int */ public function GetAirportsCount(string $q = null): ?int { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Airports/No/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Refreshes the airports list. * @return bool */ public function RefreshAirports(): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Airports/Refresh?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_POST); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Articles */ class FlyingFleet_Articles { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of articles. * @param string $q * @param ?int $vatAccount * @return DTO_Article[] */ public function GetArticles(string $q = null, ?int $vatAccount = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Articles/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&vatAccount=" . urlEncode($vatAccount == null ? "" : json_encode($vatAccount)) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the number of articles. * @param string $q * @return int */ public function GetArticlesCount(string $q = null): ?int { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Articles/No/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the article information based on the provided id * @param int $id * @return DTO_Article */ public function GetArticleById(int $id): ?DTO_Article { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Articles/ById/" . urlEncode($id) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new article * @param DTO_Article $article * @return DTO_Article */ public function AddArticle($article): ?DTO_Article { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Articles?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($article)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a batch of new articles * @param DTO_Article[] $articles * @return DTO_Article[] */ public function AddArticles($articles): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Articles/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($articles)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Update an article * @param DTO_Article $article * @return DTO_Article */ public function UpdateArticle($article): ?DTO_Article { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Articles?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($article)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns all the articles which are used by the fleet pricing. * @return DTO_Article[] */ public function GetArticleForAircraftCategory(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Articles/AircraftCategory?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns all the articles which are used by the fleet pricing. * @return DTO_Article[] */ public function GetArticleForAircraftNoiseWeight(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Articles/AircraftNoiseWeight?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns all the articles which are used by the fleet pricing. * @return DTO_ArticlePrice[] */ public function GetArticleRentingPrices(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Articles/ArticlePrices/Renting?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns all the articles which are used by the fleet pricing. * @return DTO_ArticlePrice[] */ public function GetArticleLandingPrices(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Articles/ArticlePrices/Landing?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Authorization */ class FlyingFleet_Auth { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Tries to log in a user. * @param string $email * @param string $password * @return string */ public function Login(string $email, string $password): ?string { $request = new HTTP_Request2($this->parent->url . "api/Auth?email=" . urlEncode($email) . "&password=" . urlEncode($password), HTTP_Request2::METHOD_POST); $response = $request->send(); if($response->getStatus() == 200) { $this->parent->token = $response->getBody(); return $this->parent->token; } else { $this->parent->token = null; throw new Exception("Not authorized"); } } /** * Logout a user. * @return bool */ public function Logout(): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Auth?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_DELETE); $response = $request->send(); $this->parent->token = null; return null; } /** * Refresh a token (to avoid a timeout). * @return bool */ public function Refresh(): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Auth?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API to access the backups */ class FlyingFleet_Backups { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of files in the backup folder * @return DTO_DocumentInfo[] */ public function GetList(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Backups?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the file from the backup folder as binary content * @param string $filename */ public function GetFile(string $filename) { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Backups/" . urlEncode($filename) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } public function GetPowershell() { $request = new HTTP_Request2($this->parent->url . "api/Backups/Powershell", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the bills */ class FlyingFleet_Bill { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * API to check the status of the billing * @return string */ public function Status(): ?string { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Bill/Status?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * API to recalculate the bill total * @param int $billId * @return bool */ public function ReCalc(int $billId): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Bill/ReCalc/" . urlEncode($billId) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * API to recalculate the bill total * @param int $nbMonths * @return bool */ public function ReCalcLast(int $nbMonths): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Bill/ReCalcLast/" . urlEncode($nbMonths) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Calendar */ class FlyingFleet_Calendar { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Get the calendar data for a given week. Authentification through the session (used by the web interface). * @param string $startDate * @return DTO_CalendarData */ public function ReadCalendarWeb(string $startDate = null): ?DTO_CalendarData { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Calendar/" . urlEncode($startDate) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Set the user preference for a given reservation type. * @param int $resType * @param string $color */ public function ChangeColor(int $resType, string $color) { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Calendar/ChangeColor/" . urlEncode($resType) . "?token=" . urlEncode($this->parent->token) . "&color=" . urlEncode($color), HTTP_Request2::METHOD_POST); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Toggle the visibility of a given aircraft from the calendar. * @param string $callSign */ public function ChangeVisibilityWeb(string $callSign) { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Calendar/ChangeVisibility/" . urlEncode($callSign) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } public function ChangeOrder(string $order) { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Calendar/ChangeOrder?token=" . urlEncode($this->parent->token) . "&order=" . urlEncode($order), HTTP_Request2::METHOD_POST); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Checks if a reservation exists for a given date range. * @param string $c * @param string $s * @param string $e * @param ?int $id * @return bool */ public function CheckDate(string $c, string $s, string $e, ?int $id): ?bool { $request = new HTTP_Request2($this->parent->url . "api/Calendar/CheckDate?c=" . urlEncode($c) . "&s=" . urlEncode($s) . "&e=" . urlEncode($e) . "&id=" . urlEncode($id == null ? "" : json_encode($id)), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Catalogs */ class FlyingFleet_Catalogs { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Return the list of catalogs * @param string $q * @return DTO_Catalog[] */ public function GetCatalogs(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Catalogs?token=" . urlEncode($this->parent->token) . "&q=" . urlEncode($q) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Currencies */ class FlyingFleet_Currencies { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of currencies. * @param string $q * @return DTO_Currency[] */ public function GetCurrencies(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Currencies/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the count of currencies. * @param string $q * @return int */ public function GetCurrenciesCount(string $q = null): ?int { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Currencies/No/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For diagnostic purpose */ class FlyingFleet_Diagnostic { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns system information like CPU, Memory, or Swap usage. * @return DTO_DiagnosticInfo */ public function GetSystemInformation(): ?DTO_DiagnosticInfo { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Diagnostic?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Reset the caches. * @return bool */ public function ResetCache(): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Diagnostic/ResetCache?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Documents */ class FlyingFleet_Documents { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Get the list of all the documents known * @param string $q * @return DTO_Document[] */ public function GetDocuments(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Documents/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Create a document & its path * @param string $path * @param string $filename * @param int[] $data * @return bool */ public function CreateDocument($data, string $path, string $filename): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Documents?token=" . urlEncode($this->parent->token) . "&path=" . urlEncode($path) . "&filename=" . urlEncode($filename), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($data)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Finances account */ class FlyingFleet_Finances { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of all the VAT Accounts. * @return DTO_VatAccount[] */ public function GetVatAccounts(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/VatAccounts?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Delete a VAT Account. * @param int $id * @return bool */ public function DeleteVatAccount(int $id): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/VatAccount?token=" . urlEncode($this->parent->token) . "&id=" . urlEncode($id == null ? "" : json_encode($id)), HTTP_Request2::METHOD_DELETE); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Add a VAT Account. * @param DTO_VatAccount $account * @return DTO_VatAccount */ public function AddVatAccount($account): ?DTO_VatAccount { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/VatAccount?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($account)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Update a VAT Account. * @param DTO_VatAccount $account * @return DTO_VatAccount */ public function UpdateVatAccount($account): ?DTO_VatAccount { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/VatAccount?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($account)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the list of all the Accounts Plan. * @param int $vatId * @return DTO_AccountPlan[] */ public function GetAccounts(int $vatId): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/Accounts/" . urlEncode($vatId) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Delete an Account Plan. * @param int $id * @return bool */ public function DeleteAccount(int $id): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/Account?token=" . urlEncode($this->parent->token) . "&id=" . urlEncode($id == null ? "" : json_encode($id)), HTTP_Request2::METHOD_DELETE); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Add an Account Plan. * @param DTO_AccountPlan $account * @return DTO_AccountPlan */ public function AddAccount($account): ?DTO_AccountPlan { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/Account?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($account)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Update an Account Plan. * @param DTO_AccountPlan $account * @return DTO_AccountPlan */ public function ChangeAccount($account): ?DTO_AccountPlan { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/Account?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($account)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get all VAT Account Types * @return DTO_VatType[] */ public function GetVatTypes(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/VatTypes?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get all VAT Account Types for a given VAT * @param int $vatId * @return DTO_VatType[] */ public function GetVatTypesById(int $vatId): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/VatTypes/" . urlEncode($vatId) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Delete a VAT Account Type. * @param int $id * @return bool */ public function DeleteVatType(int $id): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/VatType?token=" . urlEncode($this->parent->token) . "&id=" . urlEncode($id == null ? "" : json_encode($id)), HTTP_Request2::METHOD_DELETE); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Add a VAT Account Type. * @param DTO_VatType $vatType * @return DTO_VatType */ public function AddVatType($vatType): ?DTO_VatType { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/VatType?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($vatType)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Update a VAT Account Type. * @param DTO_VatType $vatType * @return DTO_VatType */ public function ChangeVatType($vatType): ?DTO_VatType { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Finances/VatType?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($vatType)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the FlightActivityTypes */ class FlyingFleet_FlightActivityTypes { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Get the list of all the reservation types known * @param string $q * @return DTO_FlightActivityType[] */ public function GetFlightActivityType(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/FlightActivityTypes/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Instructions */ class FlyingFleet_Instructions { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Return the statistics about the instructions * @return DTO_TableStat */ public function GetStats(): ?DTO_TableStat { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Instructions/Stats?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the list of instructions between two dates. * @param ?string $start * @param ?string $end * @return DTO_Instruction[] */ public function GetInstructions(?string $start, ?string $end): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Instructions?token=" . urlEncode($this->parent->token) . "&start=" . urlEncode($start == null ? "" : json_encode($start)) . "&end=" . urlEncode($end == null ? "" : json_encode($end)), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the list of instruction types. * @return DTO_IdName[] */ public function GetInstructionTypes(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Instructions/Types?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new instruction * @param DTO_Instruction $instruction * @return DTO_Instruction */ public function AddInstruction($instruction): ?DTO_Instruction { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Instructions?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($instruction)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new instructions * @param DTO_Instruction[] $instructions * @return DTO_Instruction[] */ public function AddInstructions($instructions): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Instructions/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($instructions)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Update an instruction * @param DTO_Instruction $instruction * @return DTO_Instruction */ public function UpdateInstruction($instruction): ?DTO_Instruction { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Instructions?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($instruction)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Delete completely an instruction * @param int $id * @return bool */ public function DeleteInstruction(int $id): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Instructions?token=" . urlEncode($this->parent->token) . "&id=" . urlEncode($id == null ? "" : json_encode($id)), HTTP_Request2::METHOD_DELETE); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Delete a bunch of instructions * @param int[] $ids * @return bool */ public function DeleteInstructions($ids): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Instructions/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_DELETE); $request->setBody(json_encode($ids)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Checks if the current user has instructions * @return bool */ public function HasInstructions(): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Instructions/Check?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Instructions Types */ class FlyingFleet_InstructionTypes { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of instruction types. * @param string $q * @return DTO_IdName[] */ public function GetInstructionTypes(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/InstructionTypes/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the instruction type information based on the provided id * @param int $id * @return DTO_IdName */ public function GetInstructionType(int $id): ?DTO_IdName { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/InstructionTypes/ById/" . urlEncode($id) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the home Links */ class FlyingFleet_Links { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Get the list of all the links known * @param string $q * @return DTO_HomeLink[] */ public function GetLinks(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Links/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Add a new home link * @param DTO_HomeLink $link * @return DTO_HomeLink */ public function AddLink($link): ?DTO_HomeLink { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Links?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($link)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the MemberMembership */ class FlyingFleet_MemberMemberships { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Add a membership to a member * @param DTO_MemberMembership $memberMembership * @return DTO_MemberMembership */ public function AddMemberMembership($memberMembership): ?DTO_MemberMembership { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/MemberMemberships?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_POST); $request->setBody(json_encode($memberMembership)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Remove a membership from a member * @param int $memberId * @param int $membershipId * @return bool */ public function RemoveMemberMembership(int $memberId, int $membershipId): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/MemberMemberships/" . urlEncode($memberId) . "?token=" . urlEncode($this->parent->token) . "&membershipId=" . urlEncode($membershipId == null ? "" : json_encode($membershipId)), HTTP_Request2::METHOD_DELETE); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Delete all memberships of a member * @param int $memberId * @return bool */ public function DeleteMemberMemberships(int $memberId): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/MemberMemberships/AllMembershipsOf?token=" . urlEncode($this->parent->token) . "&memberId=" . urlEncode($memberId == null ? "" : json_encode($memberId)), HTTP_Request2::METHOD_DELETE); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Members */ class FlyingFleet_Members { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of members. * @param string $q * @return DTO_Member[] */ public function GetMembers(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the list of members. * @param string $q * @return DTO_Member[] */ public function GetInstructors(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/Instructors/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the count of members. * @param string $q * @return int */ public function GetMembersCount(string $q = null): ?int { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/No/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the member information based on the provided id * @param int $id * @return DTO_Member */ public function GetMemberById(int $id): ?DTO_Member { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/ById/" . urlEncode($id) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the member history * @param int $id * @return DTO_MemberHistory[] */ public function GetMemberHistoryId(int $id): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/History/" . urlEncode($id) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Add one history entry to a member * @param DTO_MemberHistory $history * @return DTO_MemberHistory */ public function AddMemberHistory($history): ?DTO_MemberHistory { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/History?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($history)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Add multiple histories * @param DTO_MemberHistory[] $histories * @return DTO_MemberHistory[] */ public function AddMemberHistories($histories): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/History/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($histories)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new member * @param DTO_Member $member * @return DTO_Member */ public function AddMember($member): ?DTO_Member { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($member)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a batch of new members * @param DTO_Member[] $members * @return DTO_Member[] */ public function AddMembers($members): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($members)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Update a member * @param DTO_Member $member * @return DTO_Member */ public function UpdateMember($member): ?DTO_Member { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($member)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Add roles to a member * @param int $memberId * @param int[] $roles * @return bool */ public function AddRoles($roles, int $memberId): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/" . urlEncode($memberId) . "/Roles?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($roles)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Remove roles from a member * @param int $memberId * @param int[] $roles * @return bool */ public function RemoveRoles($roles, int $memberId): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/" . urlEncode($memberId) . "/Roles?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_DELETE); $request->setBody(json_encode($roles)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Set the allowed aircraft categories for a given user * @param int $memberId * @param int[] $aircraftCategories * @return bool */ public function SetCategories($aircraftCategories, int $memberId): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/" . urlEncode($memberId) . "/AllowedCategories?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($aircraftCategories)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Delete a member * @param int $id * @return bool */ public function DeleteMember(int $id): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members?token=" . urlEncode($this->parent->token) . "&id=" . urlEncode($id == null ? "" : json_encode($id)), HTTP_Request2::METHOD_DELETE); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Clean cache and wait for rebuild * @return bool */ public function CleanCache(): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Members/CleanCache?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Membership */ class FlyingFleet_Memberships { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of memberships. * @param string $q * @return DTO_IdName[] */ public function GetMemberships(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Memberships/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the number of memberships known. * @param string $q * @return int */ public function GetMembershipCount(string $q = null): ?int { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Memberships/No/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the membership information based on the provided id. * @param int $id * @return DTO_IdName */ public function GetMembershipById(int $id): ?DTO_IdName { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Memberships/ById/" . urlEncode($id) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Aircraft Movements */ class FlyingFleet_Movements { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of the last 100 movements. * @return DTO_FlightLog[] */ public function Lasts(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Movements/Lasts?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the list of the arrival sectors. * @return DTO_IdName[] */ public function ArrivalSectors(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Movements/ArrivalSectors?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the list of the departure sectors. * @return DTO_IdName[] */ public function DepartureRoutes(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Movements/DepartureRoutes?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the list of the runways. * @return DTO_IdName[] */ public function Runways(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Movements/Runways?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Return the statistics about the movements * @return DTO_TableStat */ public function GetStats(): ?DTO_TableStat { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Movements/Stats?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the list of the last 100 movements. * @param ?string $start * @param ?string $end * @return DTO_FlightLog[] */ public function GetMovements(?string $start = null, ?string $end = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Movements?token=" . urlEncode($this->parent->token) . "&start=" . urlEncode($start == null ? "" : json_encode($start)) . "&end=" . urlEncode($end == null ? "" : json_encode($end)) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new movement * @param DTO_FlightLog $movement * @return DTO_FlightLog */ public function AddMovement($movement): ?DTO_FlightLog { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Movements?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($movement)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } public function DeleteMovements($movementIds): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Movements/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_DELETE); $request->setBody(json_encode($movementIds)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert new movements * @param DTO_FlightLog[] $movements * @return DTO_FlightLog[] */ public function AddMovements($movements): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Movements/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($movements)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Clean cache and wait for rebuild * @return bool */ public function CleanCache(): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Movements/CleanCache?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the News */ class FlyingFleet_News { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Get the list of all the news known * @param string $q * @return DTO_News[] */ public function GetNews(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/News/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Inserts a news * @param DTO_News $news * @return DTO_News */ public function AddNews($news): ?DTO_News { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/News?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($news)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Attaches a document to a news * @param int $newsId * @param string $filename * @param int[] $data * @return bool */ public function AddNewsAttachement(int $newsId, string $filename, array $data): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/News/Attachement?token=" . urlEncode($this->parent->token) . "&newsId=" . urlEncode($newsId == null ? "" : json_encode($newsId)) . "&filename=" . urlEncode($filename) . "&data=" . urlEncode($data == null ? "" : json_encode($data)), HTTP_Request2::METHOD_PUT); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Reservations (not directly used by the Calendar UI) */ class FlyingFleet_Reservations { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Return the statistics about the reservations * @return DTO_TableStat */ public function GetStats(): ?DTO_TableStat { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Reservations/Stats?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the list of reservations between two dates. * @param ?string $start * @param ?string $end * @return DTO_Reservation[] */ public function GetReservations(?string $start, ?string $end): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Reservations?token=" . urlEncode($this->parent->token) . "&start=" . urlEncode($start == null ? "" : json_encode($start)) . "&end=" . urlEncode($end == null ? "" : json_encode($end)), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new reservation * @param DTO_Reservation $reservation * @return DTO_Reservation */ public function AddReservation($reservation): ?DTO_Reservation { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Reservations?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($reservation)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new batch of reservations * @param DTO_Reservation[] $reservations * @return DTO_Reservation[] */ public function AddReservations($reservations): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Reservations/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($reservations)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Update a reservation * @param DTO_Reservation $reservation * @return DTO_Reservation */ public function UpdateReservation($reservation): ?DTO_Reservation { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Reservations?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($reservation)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Delete a reservation * @param int $id * @return bool */ public function DeleteReservation(int $id): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Reservations?token=" . urlEncode($this->parent->token) . "&id=" . urlEncode($id == null ? "" : json_encode($id)), HTTP_Request2::METHOD_DELETE); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Delete a batch of reservations * @param int[] $ids * @param bool $completely * @return bool */ public function DeleteReservations($ids, bool $completely = False): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Reservations/Batch?token=" . urlEncode($this->parent->token) . "&completely=" . urlEncode($completely == null ? "" : json_encode($completely)), HTTP_Request2::METHOD_DELETE); $request->setBody(json_encode($ids)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Reservation Types */ class FlyingFleet_ReservationTypes { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Get the list of all the reservation types known * @param string $q * @return DTO_ReservationType[] */ public function GetReservationTypes(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/ReservationTypes/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Right Types */ class FlyingFleet_RightTypes { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of right types. * @return DTO_IdName[] */ public function GetRightTypes(): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/RightTypes?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Role Types */ class FlyingFleet_RoleTypes { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of right types. * @param string $q * @return DTO_IdName[] */ public function GetRolesTypes(string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/RoleTypes/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the count of right types. * @param string $q * @return int */ public function GetRoleTypeCount(string $q = null): ?int { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/RoleTypes/No/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the role type information based on the provided id * @param int $id * @return DTO_IdName */ public function GetRoleType(int $id): ?DTO_IdName { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/RoleTypes/ById/" . urlEncode($id) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new role type * @param DTO_IdName $role * @return DTO_IdName */ public function AddRoleType(DTO_IdName $role): ?DTO_IdName { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/RoleTypes?token=" . urlEncode($this->parent->token) . "&role=" . urlEncode($role == null ? "" : json_encode($role)), HTTP_Request2::METHOD_PUT); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a batch of new members * @param DTO_IdName[] $roles * @return DTO_IdName[] */ public function AddRoleTypes(array $roles): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/RoleTypes/Batch?token=" . urlEncode($this->parent->token) . "&roles=" . urlEncode($roles == null ? "" : json_encode($roles)), HTTP_Request2::METHOD_PUT); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Set the rights for a given role * @param int $roleId * @param int[] $rights * @return bool */ public function SetRoleRight($rights, int $roleId): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/RoleTypes/Rights?token=" . urlEncode($this->parent->token) . "&roleId=" . urlEncode($roleId == null ? "" : json_encode($roleId)), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($rights)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Global Search */ class FlyingFleet_Search { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns all the possible match for a given string. * @param string $q * @return DTO_SearchResult[] */ public function Search(string $q): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Search/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the TechLog */ class FlyingFleet_TechLog { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Return the statistics about the techlogs * @return DTO_TableStat */ public function GetStats(): ?DTO_TableStat { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/TechLog/Stats?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the techlog for a given aircraft. * @param string $callsign * @return DTO_DisplayTechlog */ public function GetTechLogsByCallSign(string $callsign): ?DTO_DisplayTechlog { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/TechLog/ByCallSign/" . urlEncode($callsign) . "?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Returns the list of the entries. * @param ?string $start * @param ?string $end * @return DTO_TechLog[] */ public function GetLogs(?string $start = null, ?string $end = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/TechLog?token=" . urlEncode($this->parent->token) . "&start=" . urlEncode($start == null ? "" : json_encode($start)) . "&end=" . urlEncode($end == null ? "" : json_encode($end)) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new Techlog * @param DTO_TechLog $log * @return DTO_TechLog */ public function AddEntry($log): ?DTO_TechLog { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/TechLog?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($log)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new techlogs * @param DTO_TechLog[] $logs * @return DTO_TechLog[] */ public function AddEntries($logs): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/TechLog/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($logs)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Update an existing techlog * @param DTO_TechLog $log * @return bool */ public function UpdateEntry($log): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/TechLog?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PATCH); $request->setBody(json_encode($log)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * API For the Transactions */ class FlyingFleet_Transactions { private $parent = null; public function __construct($apiObject) { $this->parent = $apiObject; } /** * Returns the list of transactions. * @param ?int $vatAccountId * @param string $q * @return DTO_Transaction[] */ public function GetTransactions(?int $vatAccountId, string $q = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Transactions/" . urlEncode($q) . "?token=" . urlEncode($this->parent->token) . "&vatAccountId=" . urlEncode($vatAccountId == null ? "" : json_encode($vatAccountId)) . "&limit=-1", HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert a new transaction. * @param DTO_Transaction $transaction * @return DTO_FlightLog */ public function AddTransaction($transaction): ?DTO_FlightLog { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Transactions?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($transaction)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Insert new transactions. * @param DTO_Transaction[] $transactions * @return DTO_Transaction[] */ public function AddTransactions($transactions): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Transactions/Batch?token=" . urlEncode($this->parent->token), HTTP_Request2::METHOD_PUT); $request->setBody(json_encode($transactions)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Get the list of bills. * @param ?int $vatAccountId * @return DTO_Bill[] */ public function GetBills(?int $vatAccountId = null): ?array { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Transactions/Bills?token=" . urlEncode($this->parent->token) . "&vatAccountId=" . urlEncode($vatAccountId == null ? "" : json_encode($vatAccountId)), HTTP_Request2::METHOD_GET); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Create a bill from transactions. * @param int[] $transactions * @param string $creationDate * @param DTO_BillStatus $status * @param ?string $paidOn * @param ?int $importId * @return DTO_Bill */ public function CreateFromTransactions($transactions, string $creationDate, DTO_BillStatus $status, ?string $paidOn, ?int $importId = null): ?DTO_Bill { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Transactions/Bill/CreateFrom?token=" . urlEncode($this->parent->token) . "&creationDate=" . urlEncode($creationDate == null ? "" : json_encode($creationDate)) . "&status=" . urlEncode($status == null ? "" : json_encode($status)) . "&paidOn=" . urlEncode($paidOn == null ? "" : json_encode($paidOn)) . "&importId=" . urlEncode($importId == null ? "" : json_encode($importId)), HTTP_Request2::METHOD_POST); $request->setBody(json_encode($transactions)); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } /** * Update the status of a bill. * @param int $billId * @param DTO_BillStatus $status * @param ?string $paidOn * @return bool */ public function UpdateBill(int $billId, DTO_BillStatus $status, ?string $paidOn): ?bool { if($this->parent->token == null) throw new Exception("Not authorized"); $request = new HTTP_Request2($this->parent->url . "api/Transactions/Bill/UpdateStatus?token=" . urlEncode($this->parent->token) . "&billId=" . urlEncode($billId == null ? "" : json_encode($billId)) . "&status=" . urlEncode($status == null ? "" : json_encode($status)) . "&paidOn=" . urlEncode($paidOn == null ? "" : json_encode($paidOn)), HTTP_Request2::METHOD_POST); $response = $request->send(); if($response->getStatus() == 200) return json_decode($response->getBody()); else return null; } } /** * FlyingFleet API. Each API class is accessible via the appropriate fields. Before calling most API calls, a call to the Auth.Login is required. */ class FlyingFleetApi { public $url = "https://demo.flying-fleet.com/"; // URL of the API to use public $token = null; /** * API For the Action History Menu */ public ?FlyingFleet_ActionHistory $ActionHistory = null; /** * API For the Aircraft Log */ public ?FlyingFleet_AircraftLogs $AircraftLogs = null; /** * API For the Aircraft Models */ public ?FlyingFleet_AircraftModels $AircraftModels = null; /** * API For the Aircrafts */ public ?FlyingFleet_Aircrafts $Aircrafts = null; /** * API For the Airports */ public ?FlyingFleet_Airports $Airports = null; /** * API For the Articles */ public ?FlyingFleet_Articles $Articles = null; /** * API For the Authorization */ public ?FlyingFleet_Auth $Auth = null; /** * API to access the backups */ public ?FlyingFleet_Backups $Backups = null; /** * API For the bills */ public ?FlyingFleet_Bill $Bill = null; /** * API For the Calendar */ public ?FlyingFleet_Calendar $Calendar = null; /** * API For the Catalogs */ public ?FlyingFleet_Catalogs $Catalogs = null; /** * API For the Currencies */ public ?FlyingFleet_Currencies $Currencies = null; /** * API For diagnostic purpose */ public ?FlyingFleet_Diagnostic $Diagnostic = null; /** * API For the Documents */ public ?FlyingFleet_Documents $Documents = null; /** * API For the Finances account */ public ?FlyingFleet_Finances $Finances = null; /** * API For the FlightActivityTypes */ public ?FlyingFleet_FlightActivityTypes $FlightActivityTypes = null; /** * API For the Instructions */ public ?FlyingFleet_Instructions $Instructions = null; /** * API For the Instructions Types */ public ?FlyingFleet_InstructionTypes $InstructionTypes = null; /** * API For the home Links */ public ?FlyingFleet_Links $Links = null; /** * API For the MemberMembership */ public ?FlyingFleet_MemberMemberships $MemberMemberships = null; /** * API For the Members */ public ?FlyingFleet_Members $Members = null; /** * API For the Membership */ public ?FlyingFleet_Memberships $Memberships = null; /** * API For the Aircraft Movements */ public ?FlyingFleet_Movements $Movements = null; /** * API For the News */ public ?FlyingFleet_News $News = null; /** * API For the Reservations (not directly used by the Calendar UI) */ public ?FlyingFleet_Reservations $Reservations = null; /** * API For the Reservation Types */ public ?FlyingFleet_ReservationTypes $ReservationTypes = null; /** * API For the Right Types */ public ?FlyingFleet_RightTypes $RightTypes = null; /** * API For the Role Types */ public ?FlyingFleet_RoleTypes $RoleTypes = null; /** * API For the Global Search */ public ?FlyingFleet_Search $Search = null; /** * API For the TechLog */ public ?FlyingFleet_TechLog $TechLog = null; /** * API For the Transactions */ public ?FlyingFleet_Transactions $Transactions = null; function __construct() { $this->ActionHistory = new FlyingFleet_ActionHistory($this); $this->AircraftLogs = new FlyingFleet_AircraftLogs($this); $this->AircraftModels = new FlyingFleet_AircraftModels($this); $this->Aircrafts = new FlyingFleet_Aircrafts($this); $this->Airports = new FlyingFleet_Airports($this); $this->Articles = new FlyingFleet_Articles($this); $this->Auth = new FlyingFleet_Auth($this); $this->Backups = new FlyingFleet_Backups($this); $this->Bill = new FlyingFleet_Bill($this); $this->Calendar = new FlyingFleet_Calendar($this); $this->Catalogs = new FlyingFleet_Catalogs($this); $this->Currencies = new FlyingFleet_Currencies($this); $this->Diagnostic = new FlyingFleet_Diagnostic($this); $this->Documents = new FlyingFleet_Documents($this); $this->Finances = new FlyingFleet_Finances($this); $this->FlightActivityTypes = new FlyingFleet_FlightActivityTypes($this); $this->Instructions = new FlyingFleet_Instructions($this); $this->InstructionTypes = new FlyingFleet_InstructionTypes($this); $this->Links = new FlyingFleet_Links($this); $this->MemberMemberships = new FlyingFleet_MemberMemberships($this); $this->Members = new FlyingFleet_Members($this); $this->Memberships = new FlyingFleet_Memberships($this); $this->Movements = new FlyingFleet_Movements($this); $this->News = new FlyingFleet_News($this); $this->Reservations = new FlyingFleet_Reservations($this); $this->ReservationTypes = new FlyingFleet_ReservationTypes($this); $this->RightTypes = new FlyingFleet_RightTypes($this); $this->RoleTypes = new FlyingFleet_RoleTypes($this); $this->Search = new FlyingFleet_Search($this); $this->TechLog = new FlyingFleet_TechLog($this); $this->Transactions = new FlyingFleet_Transactions($this); } }