// Auto generated API client for FlyingFleet using the REST interface // Requires the RestSharp NuGet package // Usage: // var a = new FlyingFleetApi.API() // a.Auth.Login("your@email.com", "your_password") // Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(a.Articles.GetArticles())); using System; using System.Collections.Generic; using System.Linq; using RestSharp; /**************************************************** * Enumerations used by the API / ****************************************************/ namespace FlyingFleetApi.Enums { public enum BillStatus : int { Open = 1; Paid = 2; Canceled = 3; Replaced = 4; Current = 5; Draft = 10; } public enum AircraftType : int { Glider = 1; PoweredGlider = 2; Airplane = 3; Balloon = 4; Helicopter = 5; Gyrocopter = 6; Airship = 7; } public enum FlightLogTypes : int { Departure = 1; Arrival = 2; Circuits = 3; ExternalArrival = 4; ExternalDeparture = 5; } public enum UnitTypes : int { Single = 1; Minutes = 2; Litters = 3; } public enum ArticleType : int { Membership = 1; FuelSale = 2; Instruction = 3; AircraftRentPricing = 4; AircraftLandingPricing = 5; AircraftStartPricing = 6; FuelReimbursement = 7; Towing = 8; Facility = 9; PaperBill = 10; TrialFlight = 11; FirstReminder = 51; SecondReminder = 52; ThirdReminder = 53; Rounding = 80; Other = 100; } public enum AccountType : int { Debitor = 1; Account = 2; MeansOfPayment = 3; TransferAccount = 4; RoundingDifference = 5; } public enum InstructionState : int { Filled = 1; Accepted = 2; Refused = 3; } public enum NewsVisibility : int { Outside = 1; Inside = 2; Both = 3; Calendar = 4; WelcomeEmail = 5; Home = 6; OPS = 7; Events = 8; Billing = 9; AircraftCategory = 10; Aircraft = 11; } public enum TechLogStatus : int { Close = 1; CRS = 2; CRS_Check = 3; DD_NotFlightRelevant = 4; DD_Restriction = 5; ForInformationOnly = 6; NotAirworthy = 7; NotFlightRelevant = 8; FlightRelevant_AOG = 9; ARC = 10; } public enum ExternalTool : int { NoExternalTool = 1; Vereinsflieger = 2; } public enum Recuring : int { NotRecuring = 0; Annually = 1; Monthly = 2; Weekly = 3; } public enum ComponentCycle : int { Hours = 1; Date = 2; } public enum ActionType : int { Register = 0; Login = 1; Logout = 2; InvalidCaptcha = 3; AdminResetPassword = 4; AdminSetPassword = 5; AdminModifyProfile = 6; AdminCreateReservationType = 7; AdminDeleteReservationType = 8; AdminEditReservationType = 9; AdminDeleteAircraft = 10; AdminDeleteMember = 11; AdminCreateAircraft = 12; AdminEditAircraft = 13; AdminCreateNews = 14; AdminEditNews = 15; AdminDeleteNews = 16; AdminDeleteArticle = 17; AdminCreateArticle = 18; AdminEditArticle = 19; AdminCreateAircraftArticle = 20; AdminEditAircraftArticle = 21; AdminDeleteAircraftArticle = 22; AdminDeleteTechlog = 23; AdminCreateTechlog = 24; AdminUpdateTechlog = 25; CreateReservation = 26; UpdateReservation = 27; DeleteReservation = 28; CreateMovement = 29; AdminCreateAircraftModel = 30; AdminEditAircraftModel = 31; AdminDeleteAircraftModel = 32; AdminRemoveMembership = 33; AdminAddMembership = 34; AdminRefuseCounterCorrection = 35; CreateInstruction = 36; InstructionAccepted = 37; InstructionRefused = 38; MinutesFlown = 39; InstructionTime = 40; Landing = 41; GoArround = 42; AdminAddMember = 43; AdminEditMember = 44; UpdateInstruction = 45; ChangedPassword = 46; EditProfile = 47; AdminDeleteVatAccount = 48; AdminCreateVatAccount = 49; AdminEditVatAccount = 50; AdminDeleteVatType = 51; AdminCreateVatType = 52; AdminEditVatType = 53; AdminDeleteAccountPlan = 54; AdminCreateAccountPlan = 55; AdminEditAccountPlan = 56; AdminDeleteCatalog = 57; AdminEditCatalog = 58; AdminCreateCatalog = 59; AdminDeleteFlightActivityType = 60; AdminCreateFlightActivityType = 61; AdminEditFlightActivityType = 62; AdminDeleteInstructionType = 63; AdminCreateInstructionType = 64; AdminEditInstructionType = 65; AdminAddRole = 66; AdminRemoveRole = 67; AdminDeleteRoleType = 68; AdminCreateRoleType = 69; AdminEditRoleType = 70; AdminCreateMembershipType = 71; AdminEditMembershipType = 72; AdminDeleteMembershipType = 73; AdminDeleteAllMemberships = 74; AdminCreateTransaction = 75; AdminAddFlightActivityTypeAccountPlan = 76; AdminDeleteFlightActivityTypeAccountPlan = 77; AdminCopyFlightActivityTypeAccountPlan = 78; AdminAddFlightActivityAircraftType = 79; AdminDeleteFlightActivityAircraftType = 80; AdminAddFlightActivityRole = 81; AdminDeleteFlightActivityRole = 82; AdminAddAircraftActivityType = 83; AdminDeleteAircraftActivityType = 84; AdminCreateShopArticle = 85; AdminEditShopArticle = 86; AdminDeleteShopArticle = 87; AdminRemoveShopArticleRequirement = 88; AdminAddShopArticleRequirement = 89; AdminDeleteAircraftCategory = 90; AdminCreateAircraftCategory = 91; AdminEditAircraftCategory = 92; AdminRemoveUserAircraftCategory = 93; AdminAddUserAircraftCategory = 94; AdminCreateMember = 95; AcceptPrivacy = 96; AdminCreateLink = 97; AdminEditLink = 98; AdminDeleteLink = 99; AdminRemoveAttachementsNews = 100; AdminDeleteCompany = 101; AdminCreateCompany = 102; AdminEditCompany = 103; AdminDeleteStockItem = 104; AdminCreateStockItem = 105; AdminEditStockItem = 106; AdminImportStockItems = 107; CamoAddAircraftComponent = 108; EditNotifications = 109; CreateAircraftLog = 110; CreateTechlog = 111; AdminDeleteCostUnit = 112; AdminCreateCostUnit = 113; AdminEditCostUnit = 114; AdminDeleteCostCenter = 115; AdminCreateCostCenter = 116; AdminEditCostCenter = 117; AdminCopyFromFlightActivityTypeAccountPlan = 118; AdminDeleteBill = 119; AdminCreateBill = 120; AdminAddTransaction = 121; AdminRemoveTransaction = 122; AdminBillMarkedAsPaid = 123; AdminBillMarkedCanceled = 124; AdminBillReplaced = 125; AdminBillFinalized = 126; AdminBillSent = 127; AdminBillingSent = 128; AdminRemindersSent = 129; AdminImportFinancialConfig = 130; AdminDeletePriceValidity = 131; AdminCreatePriceValidity = 132; AdminEditPriceValidity = 133; ModifyMovement = 134; AdminDeleteRunway = 135; AdminCreateRunway = 136; AdminEditRunway = 137; AdminDeleteArrivalSector = 138; AdminCreateArrivalSector = 139; AdminEditArrivalSector = 140; AdminDeleteDepartureRoute = 141; AdminCreateDepartureRoute = 142; AdminEditDepartureRoute = 143; AdminDeleteHoliday = 144; AdminCreateHoliday = 145; AdminEditHoliday = 146; AdminDeleteRegistrationRequest = 147; AdminCreateRegistrationRequest = 148; AdminEditRegistrationRequest = 149; AddMemberCredits = 150; AdminBillReOpened = 151; OnlinePurchase = 152; DeleteMovement = 153; AdminAddMemberVatAccountLink = 154; AdminRemoveMemberVatAccountLink = 155; AdminAddAircraftModel = 156; AdminAddAircraft = 157; AdminSetGlobalCss = 158; AdminSetPrivateCss = 159; AdminRemovedGlobalCss = 160; AdminRemovedPrivateCss = 161; AdminAddArticleAircraftType = 162; AdminRemoveArticleAircraftType = 163; AdminAddArticleAircraftCategory = 164; AdminRemoveArticleAircraftCategory = 165; } public enum MemberDefaultType : int { ReservationType = 1; InstructorId = 2; LastMovementCallSign = 3; ReservationInstructor = 4; LastInstructionType = 5; LastFlightActivityType = 6; CalendarReminder = 7; ExportRoles = 8; ExportMemberships = 9; PlannedTime = 10; } public enum NotificationCategory : int { System = 0; ChangeReservation = 1; NewBilling = 2; NewInstruction = 3; Newsletter = 4; NewReservation = 5; CancelReservation = 6; Maintenance = 7; Instructors = 8; Accounting = 9; } public enum MembershipValidity : int { Forever = 1; Yearly = 2; Monthly = 3; CalendarYear = 4; TillSpecified = 5; } public enum MembershipType : int { Generic = 1; Aircraft = 2; } public enum PreferredForAircraftType : int { All = 0; Motor = 1; Glider = 2; } public enum DocumentFor : int { FlightLogCounterCorrection = 1; FlightLogFuel = 2; News = 3; } } /**************************************************** * DTOs used by the API * ****************************************************/ namespace FlyingFleetApi.DTOs { public class VisitedPage { public string URL {get; set; } public string Title {get; set; } public DateTime When {get; set; } public int NbMinutes {get; set; } public string Details {get; set; } } public class AircraftLog { public int Id {get; set; } public int FlightActivityTypeId {get; set; } public int AircraftId {get; set; } public int? StartCounter {get; set; } public int? EndCounter {get; set; } public int MemberId {get; set; } public int? InstructorId {get; set; } public DateTime? DepartureTime {get; set; } public string StartPlace {get; set; } public DateTime? ArrivalTime {get; set; } public string LandingPlace {get; set; } public int? NbLandings {get; set; } public decimal? FuelLitters {get; set; } public string CallSign {get; set; } public string FlightActivityType {get; set; } public string Member {get; set; } } public class AircraftModel { public int Id {get; set; } public string ICAOType {get; set; } public string Manufacturer {get; set; } public string ModelType {get; set; } public string MarketingDesignation {get; set; } public Aircraft[] Aircrafts {get; set; } public string DisplayName {get; set; } } public class Aircraft { public int Id {get; set; } public string CallSign {get; set; } public string Display {get; set; } public bool Visible {get; set; } public int Order {get; set; } public AircraftType AircraftType {get; set; } public bool? InCAMO {get; set; } public bool? CanBeBooked {get; set; } public string TimeCounter {get; set; } public int? ModelId {get; set; } public int? NextControl {get; set; } public string NextControlTimer {get; set; } public bool? HomeBase {get; set; } public int? LandingCounter {get; set; } public string MainOwner {get; set; } public int? MainMemberId {get; set; } public DateTime? NextAnnual {get; set; } public DateTime? NextArcReview {get; set; } public DateTime? NextArcExtension {get; set; } public int? AircraftCategoryId {get; set; } public FlightLogTypes? LastLogType {get; set; } public string LastAirport {get; set; } public FlightActivityType[] AllowedActivities {get; set; } public string ExpectedDestination {get; set; } public bool? IsValid {get; set; } } public class AircraftCAMO { public string CallSign {get; set; } public int? TimeCounter {get; set; } public string Remaining {get; set; } public int? LandingCounter {get; set; } public int? NextControl {get; set; } public int? NextControlTimer {get; set; } public DateTime? NextAnnual {get; set; } public DateTime? NextArcReview {get; set; } public DateTime? NextArcExtension {get; set; } } public class AircraftCategory { public int Id {get; set; } public string Name {get; set; } public string Description {get; set; } public int? NbPlaces {get; set; } public bool? IsActive {get; set; } } public class IdName { public int Id {get; set; } public string Name {get; set; } } public class Airport { public string ICAO {get; set; } public string Name {get; set; } public string Display {get; set; } } public class Article { public int Id {get; set; } public int CatalogId {get; set; } public string Description {get; set; } public string Display {get; set; } public decimal PricePerUnit {get; set; } public UnitTypes Unit {get; set; } public bool? IsValid {get; set; } public ArticleType ArticleType {get; set; } public int? AircraftCategoryId {get; set; } public int? MembershipId {get; set; } public int? RequiredAdditionalMembershipId {get; set; } public int? SupersedeId {get; set; } public int? AccountPlanId {get; set; } public int? VatTypeId {get; set; } public int? FuelCardArticleId {get; set; } public int? CostCenterId {get; set; } public int? CostUnitId {get; set; } public string ImportId {get; set; } } public class ArticlePrice { public int Id {get; set; } public int ArticleId {get; set; } public decimal PricePerUnit {get; set; } public int? AircraftCategoryId {get; set; } public int? MembershipId {get; set; } public int? AircraftWeightCategoryId {get; set; } public int? AircraftNoiseCategoryId {get; set; } public int? PriceValidityId {get; set; } } public class DocumentInfo { public string Name {get; set; } public string Size {get; set; } public string Date {get; set; } } public class CalendarData { public Aircraft[] Aircrafts {get; set; } public CalendarReservation[] Reservations {get; set; } public DateTime Start {get; set; } public DateTime End {get; set; } public ReservationType[] ReservationTypes {get; set; } public int WeekNumber {get; set; } public CalendarReservation[] OwnEntries {get; set; } public WeatherForecast[] Weather {get; set; } public int SunRise {get; set; } public int SunSet {get; set; } public AircraftLog[] AircraftLogs {get; set; } public CalendarHoliday[] Holidays {get; set; } } public class Catalog { public int Id {get; set; } public string Name {get; set; } public DateTime? ValidFrom {get; set; } public DateTime? ValidTo {get; set; } public bool? IsActive {get; set; } } public class Currency { public string ShortName {get; set; } public string Name {get; set; } public string Display {get; set; } } public class DiagnosticInfo { public double CPULoad {get; set; } public double SwapLoad {get; set; } public double MemoryLoad {get; set; } } public class Document { public string Filename {get; set; } public string Path {get; set; } } public class VatAccount { public int Id {get; set; } public string Company {get; set; } public string Title {get; set; } public string FirstName {get; set; } public string LastName {get; set; } public string Address {get; set; } public string ZipCode {get; set; } public string City {get; set; } public string Country {get; set; } public string AccountNumber {get; set; } public string ReferenceNumber {get; set; } public string VatNumber {get; set; } public string Email {get; set; } public string PhoneNumber {get; set; } public string BankName {get; set; } public string BankLocation {get; set; } public int? ImportId {get; set; } public DateTime? ValidFrom {get; set; } public DateTime? ValidTill {get; set; } public int? MainDebtorId {get; set; } public int? PaymentTerms {get; set; } } public class AccountPlan { public int Id {get; set; } public string Name {get; set; } public string AccountNumber {get; set; } public AccountType AccountType {get; set; } public int? ImportId {get; set; } public int VatAccountId {get; set; } } public class VatType { public int Id {get; set; } public string ShortName {get; set; } public string Name {get; set; } public string AccountNumber {get; set; } public decimal Amount {get; set; } public int VatAccountId {get; set; } public int? ImportId {get; set; } } public class FlightActivityType { public int Id {get; set; } public string Name {get; set; } public bool? RequiresInstructor {get; set; } public bool? IsTowing {get; set; } } public class TableStat { public DateTime LastEntry {get; set; } public int LastEntryId {get; set; } public int NbEntries {get; set; } } public class Instruction { public int Id {get; set; } public int InstructorId {get; set; } public int StudentId {get; set; } public DateTime StartDate {get; set; } public DateTime EndDate {get; set; } public int NbMinutes {get; set; } public InstructionState State {get; set; } public string Comment {get; set; } public int InstructionTypeId {get; set; } } public class HomeLink { public int Id {get; set; } public string Name {get; set; } public int DisplayOrder {get; set; } public string URL {get; set; } } public class MemberMembership { public int MemberId {get; set; } public int MembershipId {get; set; } public DateTime CreatedOn {get; set; } public DateTime ValidTill {get; set; } } public class Member { public int Id {get; set; } public string Company {get; set; } public string Title {get; set; } public string FullName {get; set; } public string Email {get; set; } public string Display {get; set; } public string FirstName {get; set; } public string LastName {get; set; } public string Password {get; set; } public string Address {get; set; } public string Phone {get; set; } public string ImportFrom {get; set; } public string ImportId {get; set; } public string EmergencyContact {get; set; } public DateTime? Birthday {get; set; } public DateTime? LastBooking {get; set; } public string ZipCode {get; set; } public string City {get; set; } public string Country {get; set; } public int? Caution {get; set; } public bool CanLog {get; set; } public bool? Verified {get; set; } public string LicenseNumber {get; set; } public DateTime? RatingValidTill {get; set; } public DateTime? MedicalValidTill {get; set; } public DateTime? LanguageValidTill {get; set; } public DateTime? FiCriValidTill {get; set; } public DateTime? RefreshFlightDue {get; set; } public DateTime? TmgValidTill {get; set; } } public class MemberHistory { public int Id {get; set; } public int MemberId {get; set; } public int WrittenById {get; set; } public string WrittenBy {get; set; } public DateTime StoredWhen {get; set; } public string Content {get; set; } } public class FlightLog { public int Id {get; set; } public FlightLogTypes LogType {get; set; } public int FlightActivityTypeId {get; set; } public string CallSign {get; set; } public int? AircraftId {get; set; } public string GuestPilot {get; set; } public int? MemberId {get; set; } public int? InstructorId {get; set; } public DateTime? DepartureTime {get; set; } public string StartPlace {get; set; } public DateTime? ArrivalTime {get; set; } public string LandingPlace {get; set; } public int? NbLandings {get; set; } public int? GoArrounds {get; set; } public int? RunwayId {get; set; } public int? ArrivalSectorId {get; set; } public int? DepartureRouteId {get; set; } public string RequestedTowingJob {get; set; } public string HiddenTowingJob {get; set; } public bool? ExternalTowingPaid {get; set; } public string Pilot {get; set; } } public class News { public int Id {get; set; } public string Title {get; set; } public string Content {get; set; } public DateTime PostedOn {get; set; } public int? PostedById {get; set; } public NewsVisibility Visibility {get; set; } } public class Reservation { public int Id {get; set; } public DateTime Start {get; set; } public DateTime End {get; set; } public int AircraftId {get; set; } public bool? IsStandby {get; set; } public bool? IsProvisory {get; set; } public bool? IsDeleted {get; set; } public int ReservationTypeId {get; set; } public int MemberId {get; set; } public int? InstructorId {get; set; } public string Comment {get; set; } public int? PlannedTime {get; set; } public DateTime? AircraftAcceptedOn {get; set; } public DateTime? AircraftReturnedOn {get; set; } } public class ReservationType { public int Id {get; set; } public string Name {get; set; } public int Priority {get; set; } public bool? CanDoubleBook {get; set; } public bool? RequiresInstructor {get; set; } public int? RequiredRightTypeId {get; set; } public string CssColor {get; set; } } public class SearchResult { public string Url {get; set; } public string Category {get; set; } public string Description {get; set; } } public class DisplayTechlog { public int? NextControl {get; set; } public string HoursRemaining {get; set; } public DisplayTechlogEntry[] Entries {get; set; } public int? NextControlTimer {get; set; } public int? TimeCounter {get; set; } } public class TechLog { public int Id {get; set; } public int? ResponseToId {get; set; } public int? ResponseById {get; set; } public int AircraftId {get; set; } public int? FlightLogId {get; set; } public int? ReportedMemberId {get; set; } public string EntryReport {get; set; } public DateTime EntryDate {get; set; } public int? DuplicateOfId {get; set; } public TechLogStatus Status {get; set; } public int? ImportId {get; set; } } public class Transaction { public int Id {get; set; } public DateTime CreatedWhen {get; set; } public int? RegisteredById {get; set; } public int MemberId {get; set; } public int? ArticleId {get; set; } public int? AircraftId {get; set; } public decimal Price {get; set; } public decimal Quantity {get; set; } public int? FlightLogId {get; set; } public int? InstructionId {get; set; } public int? ArticlePriceId {get; set; } public int? AccountPlanId {get; set; } public int? VatTypeId {get; set; } public decimal? VatAmount {get; set; } public int? BillId {get; set; } public bool? ShouldBeBilled {get; set; } public string ImportId {get; set; } public string CustomDescription {get; set; } public string Description {get; set; } } public class Bill { public int Id {get; set; } public string ReferenceNumber {get; set; } public int MemberId {get; set; } public int VatAccountId {get; set; } public decimal Total {get; set; } public int? NewBillId {get; set; } public DateTime CreatedOn {get; set; } public DateTime DueOn {get; set; } public DateTime? PaidOn {get; set; } public BillStatus Status {get; set; } public int? ImportId {get; set; } } public class CalendarReservation { public int Id {get; set; } public DateTime Start {get; set; } public DateTime End {get; set; } public string CallSign {get; set; } public bool IsStandby {get; set; } public bool IsProvisory {get; set; } public string CssColor {get; set; } public int ReservationTypeId {get; set; } public string ReservationType {get; set; } public int Priority {get; set; } public string Member {get; set; } public string LastName {get; set; } public string Phone {get; set; } public int MemberId {get; set; } public string Instructor {get; set; } public int InstructorId {get; set; } public bool OwnReservation {get; set; } public bool CanAcceptAircraft {get; set; } public bool CanReturnAircraft {get; set; } public bool AircraftAccepted {get; set; } public bool AircraftReturned {get; set; } } public class WeatherForecast { public string Date {get; set; } public string Forecast {get; set; } public string Icon {get; set; } } public class CalendarHoliday { public int Id {get; set; } public string Name {get; set; } public DateTime Date {get; set; } public Recuring Recuring {get; set; } } public class DisplayTechlogEntry { public string ReportedMember {get; set; } public string EntryReport {get; set; } public DateTime EntryDate {get; set; } public DateTime? ResolutionTime {get; set; } public string Status {get; set; } } public class CostUnit { public int Id {get; set; } public string AccountNumber {get; set; } public string Name {get; set; } public int? AppliesToVatAccountId {get; set; } public VatAccount AppliesToVatAccount {get; set; } } public class AllowedFlightActivityType { public int AicraftId {get; set; } public Aircraft Aircraft {get; set; } public int FlightActivityTypeId {get; set; } public FlightActivityType FlightActivityType {get; set; } } public class AircraftComponent { public int Id {get; set; } public int AircraftId {get; set; } public Aircraft Aircraft {get; set; } public string Name {get; set; } public ComponentCycle ComponentCycle {get; set; } public string Current {get; set; } public string Warning {get; set; } public string Error {get; set; } } public class MemberRole { public int Id {get; set; } public int RoleId {get; set; } public RoleType Role {get; set; } public int MemberId {get; set; } public Member Member {get; set; } public int? AppliesToVatAccountId {get; set; } public VatAccount AppliesToVatAccount {get; set; } public string AllowedExport {get; set; } public string AllowedReport {get; set; } } public class RegistrationRequest { public int Id {get; set; } public string Name {get; set; } } public class MemberAction { public int Id {get; set; } public int? MemberId {get; set; } public Member Member {get; set; } public string IP {get; set; } public DateTime When {get; set; } public ActionType Action {get; set; } public string Parameters {get; set; } } public class MemberDefault { public int MemberId {get; set; } public Member Member {get; set; } public MemberDefaultType DefaultType {get; set; } public string Value {get; set; } } public class MemberCalendarAircraft { public int MemberId {get; set; } public Member Member {get; set; } public int AircraftId {get; set; } public Aircraft Aircraft {get; set; } public bool? IsVisible {get; set; } public int? Order {get; set; } } public class MemberAircraftCategory { public int MemberId {get; set; } public Member Member {get; set; } public int AircraftCategoryId {get; set; } public AircraftCategory AircraftCategory {get; set; } } public class MemberWebPush { public int Id {get; set; } public int MemberId {get; set; } public Member Member {get; set; } public string EndPoint {get; set; } public string P256DH {get; set; } public string Auth {get; set; } } public class MemberBookmark { public int MemberId {get; set; } public string Url {get; set; } } public class MemberNotification { public int MemberId {get; set; } public Member Member {get; set; } public NotificationCategory Category {get; set; } } public class MemberVatAccountLink { public int MemberId {get; set; } public Member Member {get; set; } public int VatAccountId {get; set; } public VatAccount VatAccount {get; set; } } public class Membership { public int Id {get; set; } public string Name {get; set; } public MembershipValidity Validity {get; set; } public MembershipType MembershipType {get; set; } public int? ArticleId {get; set; } public Article Article {get; set; } public Article[] RequiredBy {get; set; } public Article[] RequiredAdditionallyBy {get; set; } } public class CostCenter { public int Id {get; set; } public string AccountNumber {get; set; } public string Name {get; set; } public int? AppliesToVatAccountId {get; set; } public VatAccount AppliesToVatAccount {get; set; } } public class ArticleRequiredAircraftType { public int ArticleId {get; set; } public Article Article {get; set; } public AircraftType AircraftType {get; set; } } public class ArticleRequiredAircraftCategory { public int ArticleId {get; set; } public Article Article {get; set; } public int AircraftCategoryId {get; set; } public AircraftCategory AircraftCategory {get; set; } } public class RoleType { public int Id {get; set; } public string Name {get; set; } public int? MaxNumberReservations {get; set; } public RoleRight[] Rights {get; set; } } public class Runway { public int Id {get; set; } public string Name {get; set; } public PreferredForAircraftType PreferredFor {get; set; } public string RunwayType {get; set; } } public class ArrivalSector { public int Id {get; set; } public string Name {get; set; } public PreferredForAircraftType PreferredFor {get; set; } } public class DepartureRoute { public int Id {get; set; } public string Name {get; set; } public PreferredForAircraftType PreferredFor {get; set; } } public class AttachedDocument { public int Id {get; set; } public DocumentFor DocumentFor {get; set; } public int? AttachedTo {get; set; } public string DocumentName {get; set; } public string DocumentType {get; set; } public byte[] DocumentData {get; set; } } public class PriceValidity { public int Id {get; set; } public string Name {get; set; } public DateTime ValidFrom {get; set; } public DateTime? ValidTo {get; set; } } public class AircraftWeightCategory { public int Id {get; set; } public string Name {get; set; } public int MTOW {get; set; } public bool? ForFurtherWeightBlocks {get; set; } } public class AircraftNoiseCategory { public int Id {get; set; } public string NoiseCategories {get; set; } } public class FlightTypeRequiredRole { public int FlightActivityTypeId {get; set; } public FlightActivityType FlightActivityType {get; set; } public int RoleTypeId {get; set; } public RoleType RoleType {get; set; } } public class FlightTypeRequiredAircraftType { public int FlightActivityTypeId {get; set; } public FlightActivityType FlightActivityType {get; set; } public AircraftType AircraftType {get; set; } } public class FlightTypeArticleAccountPlan { public int AccountPlanId {get; set; } public AccountPlan AccountPlan {get; set; } public int FlightActivityTypeId {get; set; } public FlightActivityType FlightActivityType {get; set; } public int ArticleId {get; set; } public Article Article {get; set; } public int VatTypeId {get; set; } public VatType VatType {get; set; } } public class RoleRight { public int RoleTypeId {get; set; } public RoleType RoleType {get; set; } public int RightTypeId {get; set; } public RightType RightType {get; set; } } public class RightType { public int Id {get; set; } public string Name {get; set; } } } /**************************************************** * Main API class * ****************************************************/ namespace FlyingFleetApi { /// /// 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 API { public string Url { get; set; } = "https://demo.flying-fleet.com/"; public Token { get; set; } /// /// API For the Action History Menu /// public class FlyingFleet_ActionHistory { private Api parent; public FlyingFleet_ActionHistory(Api api) { this.parent = api; } public VisitedPage[] GetHistory(string q = null) { using var client = new RestClient(parent.url + "api/ActionHistory/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Aircraft Log /// public class FlyingFleet_AircraftLogs { private Api parent; public FlyingFleet_AircraftLogs(Api api) { this.parent = api; } /// /// Returns the list of the last 100 movements. /// public AircraftLog[] GetLogs(DateTime? start = null, DateTime? end = null) { using var client = new RestClient(parent.url + "api/AircraftLogs"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("start", start); request.AddQueryParameter("end", end); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new aircraft log. /// public AircraftLog AddAircraftLog(AircraftLog aircraftLog) { using var client = new RestClient(parent.url + "api/AircraftLogs"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(aircraftLog); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert new aircraft logs. /// public AircraftLog[] AddAircraftLogs(AircraftLog[] aircraftLogs) { using var client = new RestClient(parent.url + "api/AircraftLogs/Batch"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(aircraftLogs); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Aircraft Models /// public class FlyingFleet_AircraftModels { private Api parent; public FlyingFleet_AircraftModels(Api api) { this.parent = api; } /// /// Get the list of all the aircraft models known /// public AircraftModel[] GetAircraftModels(string q = null) { using var client = new RestClient(parent.url + "api/AircraftModels/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Counts the number of aircraft given the optional search parameter /// public int GetAircraftModelsCount(string q = null) { using var client = new RestClient(parent.url + "api/AircraftModels/No/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the model information based on the provided id /// public AircraftModel GetAircraftModel(int id) { using var client = new RestClient(parent.url + "api/AircraftModels/ById/" + HttpUtility.UrlEncode(id)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new aircraft model /// public AircraftModel AddModel(AircraftModel model) { using var client = new RestClient(parent.url + "api/AircraftModels"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(model); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Aircrafts /// public class FlyingFleet_Aircrafts { private Api parent; public FlyingFleet_Aircrafts(Api api) { this.parent = api; } /// /// Get the list of all the aircrafts known /// public Aircraft[] GetAircrafts(string q = null, bool onlyCharter = false) { using var client = new RestClient(parent.url + "api/Aircrafts/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("onlyCharter", onlyCharter); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the number of aircrafts given the optional search parameter /// public int GetAircraftsCount(string q = null, bool onlyCharter = false) { using var client = new RestClient(parent.url + "api/Aircrafts/No/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("onlyCharter", onlyCharter); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get all the aircraft CAMO information /// public GetAircraftCamos() { using var client = new RestClient(parent.url + "api/Aircrafts/CAMO"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute<>(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the aircraft CAMO information based on the provided callsign /// public AircraftCAMO GetAircraftCamo(string callsign) { using var client = new RestClient(parent.url + "api/Aircrafts/CAMO/" + HttpUtility.UrlEncode(callsign)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the aircraft information based on the provided callsign /// public Aircraft GetAircraftByCallSign(string callsign) { using var client = new RestClient(parent.url + "api/Aircrafts/ByCallSign/" + HttpUtility.UrlEncode(callsign)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the aircraft information based on the provided id /// public Aircraft GetAircraftById(int id) { using var client = new RestClient(parent.url + "api/Aircrafts/ById/" + HttpUtility.UrlEncode(id)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Add a new aircraft /// public Aircraft UpdateAircraft(Aircraft aircraft) { using var client = new RestClient(parent.url + "api/Aircrafts"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(aircraft); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Retrieves the list of the aircrafts that can be rented /// public Aircraft[] GetAircraftsToRent() { using var client = new RestClient(parent.url + "api/Aircrafts/ToRent"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Retrieves the list of the id / names of the aircrafts categories /// public AircraftCategory[] GetAircraftsCategories() { using var client = new RestClient(parent.url + "api/Aircrafts/Categories"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Retrieves the list of the id / names of the aircrafts memberships /// public IdName[] GetAircraftsMemberships() { using var client = new RestClient(parent.url + "api/Aircrafts/Memberships"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Retrieves the list of the id / names of the aircrafts weight categories /// public IdName[] GetAircraftsWeightCategories() { using var client = new RestClient(parent.url + "api/Aircrafts/WeightCategories"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Retrieves the list of the id / names of the aircrafts noise categories /// public IdName[] GetAircraftsNoiseCategories() { using var client = new RestClient(parent.url + "api/Aircrafts/NoiseCategories"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Set the allowed flight activity types for an aircraft /// public bool SetAllowedFlightActivityTypes(int aircraftId, int[] allowedActivities) { using var client = new RestClient(parent.url + "api/Aircrafts/AllowedFlightActivityTypes"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("aircraftId", aircraftId); request.AddJsonBody(allowedActivities); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new aircraft /// public Aircraft AddAircraft(Aircraft aircraft) { using var client = new RestClient(parent.url + "api/Aircrafts"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(aircraft); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Airports /// public class FlyingFleet_Airports { private Api parent; public FlyingFleet_Airports(Api api) { this.parent = api; } /// /// Get the list of all the airports known /// public Airport[] GetAirports(string q = null) { using var client = new RestClient(parent.url + "api/Airports/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the number of airports known. /// public int GetAirportsCount(string q = null) { using var client = new RestClient(parent.url + "api/Airports/No/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Refreshes the airports list. /// public bool RefreshAirports() { using var client = new RestClient(parent.url + "api/Airports/Refresh"); var request = client.RestRequest(Method.Post); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Articles /// public class FlyingFleet_Articles { private Api parent; public FlyingFleet_Articles(Api api) { this.parent = api; } /// /// Returns the list of articles. /// public Article[] GetArticles(string q = null, int? vatAccount = null) { using var client = new RestClient(parent.url + "api/Articles/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("vatAccount", vatAccount); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the number of articles. /// public int GetArticlesCount(string q = null) { using var client = new RestClient(parent.url + "api/Articles/No/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the article information based on the provided id /// public Article GetArticleById(int id) { using var client = new RestClient(parent.url + "api/Articles/ById/" + HttpUtility.UrlEncode(id)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute
(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new article /// public Article AddArticle(Article article) { using var client = new RestClient(parent.url + "api/Articles"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(article); var response = client.Execute
(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a batch of new articles /// public Article[] AddArticles(Article[] articles) { using var client = new RestClient(parent.url + "api/Articles/Batch"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(articles); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Update an article /// public Article UpdateArticle(Article article) { using var client = new RestClient(parent.url + "api/Articles"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(article); var response = client.Execute
(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns all the articles which are used by the fleet pricing. /// public Article[] GetArticleForAircraftCategory() { using var client = new RestClient(parent.url + "api/Articles/AircraftCategory"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns all the articles which are used by the fleet pricing. /// public Article[] GetArticleForAircraftNoiseWeight() { using var client = new RestClient(parent.url + "api/Articles/AircraftNoiseWeight"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns all the articles which are used by the fleet pricing. /// public ArticlePrice[] GetArticleRentingPrices() { using var client = new RestClient(parent.url + "api/Articles/ArticlePrices/Renting"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns all the articles which are used by the fleet pricing. /// public ArticlePrice[] GetArticleLandingPrices() { using var client = new RestClient(parent.url + "api/Articles/ArticlePrices/Landing"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Authorization /// public class FlyingFleet_Auth { private Api parent; public FlyingFleet_Auth(Api api) { this.parent = api; } /// /// Tries to log in a user. /// public string Login(string email, string password) { using var client = new RestClient(parent.url + "api/Auth"); var request = client.RestRequest(Method.Post); request.AddQueryParameter("email", email); request.AddQueryParameter("password", password); var response = client.Execute(request); if(response.IsSuccessful) { parent.Token = response.Data; return parent.Token; } else { parent.Token = null; throw new Exception("Not authorized"); } } /// /// Logout a user. /// public bool Logout() { using var client = new RestClient(parent.url + "api/Auth"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); parent.token = null; } /// /// Refresh a token (to avoid a timeout). /// public bool Refresh() { using var client = new RestClient(parent.url + "api/Auth"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API to access the backups /// public class FlyingFleet_Backups { private Api parent; public FlyingFleet_Backups(Api api) { this.parent = api; } /// /// Returns the list of files in the backup folder /// public DocumentInfo[] GetList() { using var client = new RestClient(parent.url + "api/Backups"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the file from the backup folder as binary content /// public GetFile(string filename) { using var client = new RestClient(parent.url + "api/Backups/" + HttpUtility.UrlEncode(filename)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute<>(request); if(response.IsSuccessful) return response.Data; else return default; } public GetPowershell() { using var client = new RestClient(parent.url + "api/Backups/Powershell"); var request = client.RestRequest(Method.Get); var response = client.Execute<>(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the bills /// public class FlyingFleet_Bill { private Api parent; public FlyingFleet_Bill(Api api) { this.parent = api; } /// /// API to check the status of the billing /// public string Status() { using var client = new RestClient(parent.url + "api/Bill/Status"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// API to recalculate the bill total /// public bool ReCalc(int billId) { using var client = new RestClient(parent.url + "api/Bill/ReCalc/" + HttpUtility.UrlEncode(billId)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// API to recalculate the bill total /// public bool ReCalcLast(int nbMonths) { using var client = new RestClient(parent.url + "api/Bill/ReCalcLast/" + HttpUtility.UrlEncode(nbMonths)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Calendar /// public class FlyingFleet_Calendar { private Api parent; public FlyingFleet_Calendar(Api api) { this.parent = api; } /// /// Get the calendar data for a given week. Authentification through the session (used by the web interface). /// public CalendarData ReadCalendarWeb(string startDate = null) { using var client = new RestClient(parent.url + "api/Calendar/" + HttpUtility.UrlEncode(startDate)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Set the user preference for a given reservation type. /// public ChangeColor(int resType, string color) { using var client = new RestClient(parent.url + "api/Calendar/ChangeColor/" + HttpUtility.UrlEncode(resType)); var request = client.RestRequest(Method.Post); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("color", color); var response = client.Execute<>(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Toggle the visibility of a given aircraft from the calendar. /// public ChangeVisibilityWeb(string callSign) { using var client = new RestClient(parent.url + "api/Calendar/ChangeVisibility/" + HttpUtility.UrlEncode(callSign)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute<>(request); if(response.IsSuccessful) return response.Data; else return default; } public ChangeOrder(string order) { using var client = new RestClient(parent.url + "api/Calendar/ChangeOrder"); var request = client.RestRequest(Method.Post); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("order", order); var response = client.Execute<>(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Checks if a reservation exists for a given date range. /// public bool CheckDate(string c, string s, string e, int? id = null) { using var client = new RestClient(parent.url + "api/Calendar/CheckDate"); var request = client.RestRequest(Method.Get); request.AddQueryParameter("c", c); request.AddQueryParameter("s", s); request.AddQueryParameter("e", e); request.AddQueryParameter("id", id); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Catalogs /// public class FlyingFleet_Catalogs { private Api parent; public FlyingFleet_Catalogs(Api api) { this.parent = api; } /// /// Return the list of catalogs /// public Catalog[] GetCatalogs(string q = null) { using var client = new RestClient(parent.url + "api/Catalogs"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("q", q); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Currencies /// public class FlyingFleet_Currencies { private Api parent; public FlyingFleet_Currencies(Api api) { this.parent = api; } /// /// Returns the list of currencies. /// public Currency[] GetCurrencies(string q = null) { using var client = new RestClient(parent.url + "api/Currencies/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the count of currencies. /// public int GetCurrenciesCount(string q = null) { using var client = new RestClient(parent.url + "api/Currencies/No/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For diagnostic purpose /// public class FlyingFleet_Diagnostic { private Api parent; public FlyingFleet_Diagnostic(Api api) { this.parent = api; } /// /// Returns system information like CPU, Memory, or Swap usage. /// public DiagnosticInfo GetSystemInformation() { using var client = new RestClient(parent.url + "api/Diagnostic"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Reset the caches. /// public bool ResetCache() { using var client = new RestClient(parent.url + "api/Diagnostic/ResetCache"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Documents /// public class FlyingFleet_Documents { private Api parent; public FlyingFleet_Documents(Api api) { this.parent = api; } /// /// Get the list of all the documents known /// public Document[] GetDocuments(string q = null) { using var client = new RestClient(parent.url + "api/Documents/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Create a document & its path /// public bool CreateDocument(string path, string filename, byte[] data) { using var client = new RestClient(parent.url + "api/Documents"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("path", path); request.AddQueryParameter("filename", filename); request.AddJsonBody(data); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Finances account /// public class FlyingFleet_Finances { private Api parent; public FlyingFleet_Finances(Api api) { this.parent = api; } /// /// Returns the list of all the VAT Accounts. /// public VatAccount[] GetVatAccounts() { using var client = new RestClient(parent.url + "api/Finances/VatAccounts"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Delete a VAT Account. /// public bool DeleteVatAccount(int id) { using var client = new RestClient(parent.url + "api/Finances/VatAccount"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("id", id); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Add a VAT Account. /// public VatAccount AddVatAccount(VatAccount account) { using var client = new RestClient(parent.url + "api/Finances/VatAccount"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(account); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Update a VAT Account. /// public VatAccount UpdateVatAccount(VatAccount account) { using var client = new RestClient(parent.url + "api/Finances/VatAccount"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(account); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the list of all the Accounts Plan. /// public AccountPlan[] GetAccounts(int vatId) { using var client = new RestClient(parent.url + "api/Finances/Accounts/" + HttpUtility.UrlEncode(vatId)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Delete an Account Plan. /// public bool DeleteAccount(int id) { using var client = new RestClient(parent.url + "api/Finances/Account"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("id", id); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Add an Account Plan. /// public AccountPlan AddAccount(AccountPlan account) { using var client = new RestClient(parent.url + "api/Finances/Account"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(account); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Update an Account Plan. /// public AccountPlan ChangeAccount(AccountPlan account) { using var client = new RestClient(parent.url + "api/Finances/Account"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(account); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get all VAT Account Types /// public VatType[] GetVatTypes() { using var client = new RestClient(parent.url + "api/Finances/VatTypes"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get all VAT Account Types for a given VAT /// public VatType[] GetVatTypesById(int vatId) { using var client = new RestClient(parent.url + "api/Finances/VatTypes/" + HttpUtility.UrlEncode(vatId)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Delete a VAT Account Type. /// public bool DeleteVatType(int id) { using var client = new RestClient(parent.url + "api/Finances/VatType"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("id", id); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Add a VAT Account Type. /// public VatType AddVatType(VatType vatType) { using var client = new RestClient(parent.url + "api/Finances/VatType"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(vatType); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Update a VAT Account Type. /// public VatType ChangeVatType(VatType vatType) { using var client = new RestClient(parent.url + "api/Finances/VatType"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(vatType); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the FlightActivityTypes /// public class FlyingFleet_FlightActivityTypes { private Api parent; public FlyingFleet_FlightActivityTypes(Api api) { this.parent = api; } /// /// Get the list of all the reservation types known /// public FlightActivityType[] GetFlightActivityType(string q = null) { using var client = new RestClient(parent.url + "api/FlightActivityTypes/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Instructions /// public class FlyingFleet_Instructions { private Api parent; public FlyingFleet_Instructions(Api api) { this.parent = api; } /// /// Return the statistics about the instructions /// public TableStat GetStats() { using var client = new RestClient(parent.url + "api/Instructions/Stats"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the list of instructions between two dates. /// public Instruction[] GetInstructions(DateTime? start = null, DateTime? end = null) { using var client = new RestClient(parent.url + "api/Instructions"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("start", start); request.AddQueryParameter("end", end); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the list of instruction types. /// public IdName[] GetInstructionTypes() { using var client = new RestClient(parent.url + "api/Instructions/Types"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new instruction /// public Instruction AddInstruction(Instruction instruction) { using var client = new RestClient(parent.url + "api/Instructions"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(instruction); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new instructions /// public Instruction[] AddInstructions(Instruction[] instructions) { using var client = new RestClient(parent.url + "api/Instructions/Batch"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(instructions); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Update an instruction /// public Instruction UpdateInstruction(Instruction instruction) { using var client = new RestClient(parent.url + "api/Instructions"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(instruction); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Delete completely an instruction /// public bool DeleteInstruction(int id) { using var client = new RestClient(parent.url + "api/Instructions"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("id", id); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Delete a bunch of instructions /// public bool DeleteInstructions(int[] ids) { using var client = new RestClient(parent.url + "api/Instructions/Batch"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(ids); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Checks if the current user has instructions /// public bool HasInstructions() { using var client = new RestClient(parent.url + "api/Instructions/Check"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Instructions Types /// public class FlyingFleet_InstructionTypes { private Api parent; public FlyingFleet_InstructionTypes(Api api) { this.parent = api; } /// /// Returns the list of instruction types. /// public IdName[] GetInstructionTypes(string q = null) { using var client = new RestClient(parent.url + "api/InstructionTypes/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the instruction type information based on the provided id /// public IdName GetInstructionType(int id) { using var client = new RestClient(parent.url + "api/InstructionTypes/ById/" + HttpUtility.UrlEncode(id)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the home Links /// public class FlyingFleet_Links { private Api parent; public FlyingFleet_Links(Api api) { this.parent = api; } /// /// Get the list of all the links known /// public HomeLink[] GetLinks(string q = null) { using var client = new RestClient(parent.url + "api/Links/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Add a new home link /// public HomeLink AddLink(HomeLink link) { using var client = new RestClient(parent.url + "api/Links"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(link); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the MemberMembership /// public class FlyingFleet_MemberMemberships { private Api parent; public FlyingFleet_MemberMemberships(Api api) { this.parent = api; } /// /// Add a membership to a member /// public MemberMembership AddMemberMembership(MemberMembership memberMembership) { using var client = new RestClient(parent.url + "api/MemberMemberships"); var request = client.RestRequest(Method.Post); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(memberMembership); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Remove a membership from a member /// public bool RemoveMemberMembership(int memberId, int membershipId) { using var client = new RestClient(parent.url + "api/MemberMemberships/" + HttpUtility.UrlEncode(memberId)); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("membershipId", membershipId); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Delete all memberships of a member /// public bool DeleteMemberMemberships(int memberId) { using var client = new RestClient(parent.url + "api/MemberMemberships/AllMembershipsOf"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("memberId", memberId); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Members /// public class FlyingFleet_Members { private Api parent; public FlyingFleet_Members(Api api) { this.parent = api; } /// /// Returns the list of members. /// public Member[] GetMembers(string q = null) { using var client = new RestClient(parent.url + "api/Members/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the list of members. /// public Member[] GetInstructors(string q = null) { using var client = new RestClient(parent.url + "api/Members/Instructors/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the count of members. /// public int GetMembersCount(string q = null) { using var client = new RestClient(parent.url + "api/Members/No/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the member information based on the provided id /// public Member GetMemberById(int id) { using var client = new RestClient(parent.url + "api/Members/ById/" + HttpUtility.UrlEncode(id)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the member history /// public MemberHistory[] GetMemberHistoryId(int id) { using var client = new RestClient(parent.url + "api/Members/History/" + HttpUtility.UrlEncode(id)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Add one history entry to a member /// public MemberHistory AddMemberHistory(MemberHistory history) { using var client = new RestClient(parent.url + "api/Members/History"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(history); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Add multiple histories /// public MemberHistory[] AddMemberHistories(MemberHistory[] histories) { using var client = new RestClient(parent.url + "api/Members/History/Batch"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(histories); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new member /// public Member AddMember(Member member) { using var client = new RestClient(parent.url + "api/Members"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(member); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a batch of new members /// public Member[] AddMembers(Member[] members) { using var client = new RestClient(parent.url + "api/Members/Batch"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(members); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Update a member /// public Member UpdateMember(Member member) { using var client = new RestClient(parent.url + "api/Members"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(member); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Add roles to a member /// public bool AddRoles(int memberId, int[] roles) { using var client = new RestClient(parent.url + "api/Members/" + HttpUtility.UrlEncode(memberId) + "/Roles"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(roles); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Remove roles from a member /// public bool RemoveRoles(int memberId, int[] roles) { using var client = new RestClient(parent.url + "api/Members/" + HttpUtility.UrlEncode(memberId) + "/Roles"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(roles); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Set the allowed aircraft categories for a given user /// public bool SetCategories(int memberId, int[] aircraftCategories) { using var client = new RestClient(parent.url + "api/Members/" + HttpUtility.UrlEncode(memberId) + "/AllowedCategories"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(aircraftCategories); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Delete a member /// public bool DeleteMember(int id) { using var client = new RestClient(parent.url + "api/Members"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("id", id); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Clean cache and wait for rebuild /// public bool CleanCache() { using var client = new RestClient(parent.url + "api/Members/CleanCache"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Membership /// public class FlyingFleet_Memberships { private Api parent; public FlyingFleet_Memberships(Api api) { this.parent = api; } /// /// Returns the list of memberships. /// public IdName[] GetMemberships(string q = null) { using var client = new RestClient(parent.url + "api/Memberships/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the number of memberships known. /// public int GetMembershipCount(string q = null) { using var client = new RestClient(parent.url + "api/Memberships/No/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the membership information based on the provided id. /// public IdName GetMembershipById(int id) { using var client = new RestClient(parent.url + "api/Memberships/ById/" + HttpUtility.UrlEncode(id)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Aircraft Movements /// public class FlyingFleet_Movements { private Api parent; public FlyingFleet_Movements(Api api) { this.parent = api; } /// /// Returns the list of the last 100 movements. /// public FlightLog[] Lasts() { using var client = new RestClient(parent.url + "api/Movements/Lasts"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the list of the arrival sectors. /// public IdName[] ArrivalSectors() { using var client = new RestClient(parent.url + "api/Movements/ArrivalSectors"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the list of the departure sectors. /// public IdName[] DepartureRoutes() { using var client = new RestClient(parent.url + "api/Movements/DepartureRoutes"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the list of the runways. /// public IdName[] Runways() { using var client = new RestClient(parent.url + "api/Movements/Runways"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Return the statistics about the movements /// public TableStat GetStats() { using var client = new RestClient(parent.url + "api/Movements/Stats"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the list of the last 100 movements. /// public FlightLog[] GetMovements(DateTime? start = null, DateTime? end = null) { using var client = new RestClient(parent.url + "api/Movements"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("start", start); request.AddQueryParameter("end", end); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new movement /// public FlightLog AddMovement(FlightLog movement) { using var client = new RestClient(parent.url + "api/Movements"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(movement); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } public bool DeleteMovements(int[] movementIds) { using var client = new RestClient(parent.url + "api/Movements/Batch"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(movementIds); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert new movements /// public FlightLog[] AddMovements(FlightLog[] movements) { using var client = new RestClient(parent.url + "api/Movements/Batch"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(movements); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Clean cache and wait for rebuild /// public bool CleanCache() { using var client = new RestClient(parent.url + "api/Movements/CleanCache"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the News /// public class FlyingFleet_News { private Api parent; public FlyingFleet_News(Api api) { this.parent = api; } /// /// Get the list of all the news known /// public News[] GetNews(string q = null) { using var client = new RestClient(parent.url + "api/News/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Inserts a news /// public News AddNews(News news) { using var client = new RestClient(parent.url + "api/News"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(news); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Attaches a document to a news /// public bool AddNewsAttachement(int newsId, string filename, byte[] data) { using var client = new RestClient(parent.url + "api/News/Attachement"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("newsId", newsId); request.AddQueryParameter("filename", filename); request.AddQueryParameter("data", data); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Reservations (not directly used by the Calendar UI) /// public class FlyingFleet_Reservations { private Api parent; public FlyingFleet_Reservations(Api api) { this.parent = api; } /// /// Return the statistics about the reservations /// public TableStat GetStats() { using var client = new RestClient(parent.url + "api/Reservations/Stats"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the list of reservations between two dates. /// public Reservation[] GetReservations(DateTime? start = null, DateTime? end = null) { using var client = new RestClient(parent.url + "api/Reservations"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("start", start); request.AddQueryParameter("end", end); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new reservation /// public Reservation AddReservation(Reservation reservation) { using var client = new RestClient(parent.url + "api/Reservations"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(reservation); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new batch of reservations /// public Reservation[] AddReservations(Reservation[] reservations) { using var client = new RestClient(parent.url + "api/Reservations/Batch"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(reservations); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Update a reservation /// public Reservation UpdateReservation(Reservation reservation) { using var client = new RestClient(parent.url + "api/Reservations"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(reservation); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Delete a reservation /// public bool DeleteReservation(int id) { using var client = new RestClient(parent.url + "api/Reservations"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("id", id); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Delete a batch of reservations /// public bool DeleteReservations(int[] ids, bool completely = false) { using var client = new RestClient(parent.url + "api/Reservations/Batch"); var request = client.RestRequest(Method.Delete); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(ids); request.AddQueryParameter("completely", completely); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Reservation Types /// public class FlyingFleet_ReservationTypes { private Api parent; public FlyingFleet_ReservationTypes(Api api) { this.parent = api; } /// /// Get the list of all the reservation types known /// public ReservationType[] GetReservationTypes(string q = null) { using var client = new RestClient(parent.url + "api/ReservationTypes/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Right Types /// public class FlyingFleet_RightTypes { private Api parent; public FlyingFleet_RightTypes(Api api) { this.parent = api; } /// /// Returns the list of right types. /// public IdName[] GetRightTypes() { using var client = new RestClient(parent.url + "api/RightTypes"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Role Types /// public class FlyingFleet_RoleTypes { private Api parent; public FlyingFleet_RoleTypes(Api api) { this.parent = api; } /// /// Returns the list of right types. /// public IdName[] GetRolesTypes(string q = null) { using var client = new RestClient(parent.url + "api/RoleTypes/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the count of right types. /// public int GetRoleTypeCount(string q = null) { using var client = new RestClient(parent.url + "api/RoleTypes/No/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the role type information based on the provided id /// public IdName GetRoleType(int id) { using var client = new RestClient(parent.url + "api/RoleTypes/ById/" + HttpUtility.UrlEncode(id)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new role type /// public IdName AddRoleType(IdName role) { using var client = new RestClient(parent.url + "api/RoleTypes"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("role", role); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a batch of new members /// public IdName[] AddRoleTypes(IdName[] roles) { using var client = new RestClient(parent.url + "api/RoleTypes/Batch"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("roles", roles); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Set the rights for a given role /// public bool SetRoleRight(int roleId, int[] rights) { using var client = new RestClient(parent.url + "api/RoleTypes/Rights"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("roleId", roleId); request.AddJsonBody(rights); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Global Search /// public class FlyingFleet_Search { private Api parent; public FlyingFleet_Search(Api api) { this.parent = api; } /// /// Returns all the possible match for a given string. /// public SearchResult[] Search(string q) { using var client = new RestClient(parent.url + "api/Search/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the TechLog /// public class FlyingFleet_TechLog { private Api parent; public FlyingFleet_TechLog(Api api) { this.parent = api; } /// /// Return the statistics about the techlogs /// public TableStat GetStats() { using var client = new RestClient(parent.url + "api/TechLog/Stats"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the techlog for a given aircraft. /// public DisplayTechlog GetTechLogsByCallSign(string callsign) { using var client = new RestClient(parent.url + "api/TechLog/ByCallSign/" + HttpUtility.UrlEncode(callsign)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Returns the list of the entries. /// public TechLog[] GetLogs(DateTime? start = null, DateTime? end = null) { using var client = new RestClient(parent.url + "api/TechLog"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("start", start); request.AddQueryParameter("end", end); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new Techlog /// public TechLog AddEntry(TechLog log) { using var client = new RestClient(parent.url + "api/TechLog"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(log); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new techlogs /// public TechLog[] AddEntries(TechLog[] logs) { using var client = new RestClient(parent.url + "api/TechLog/Batch"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(logs); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Update an existing techlog /// public bool UpdateEntry(TechLog log) { using var client = new RestClient(parent.url + "api/TechLog"); var request = client.RestRequest(Method.Patch); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(log); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Transactions /// public class FlyingFleet_Transactions { private Api parent; public FlyingFleet_Transactions(Api api) { this.parent = api; } /// /// Returns the list of transactions. /// public Transaction[] GetTransactions(int? vatAccountId = null, string q = null) { using var client = new RestClient(parent.url + "api/Transactions/" + HttpUtility.UrlEncode(q)); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("vatAccountId", vatAccountId); request.AddQueryParameter("limit", "-1"); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert a new transaction. /// public FlightLog AddTransaction(Transaction transaction) { using var client = new RestClient(parent.url + "api/Transactions"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(transaction); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Insert new transactions. /// public Transaction[] AddTransactions(Transaction[] transactions) { using var client = new RestClient(parent.url + "api/Transactions/Batch"); var request = client.RestRequest(Method.Put); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(transactions); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Get the list of bills. /// public Bill[] GetBills(int? vatAccountId = null) { using var client = new RestClient(parent.url + "api/Transactions/Bills"); var request = client.RestRequest(Method.Get); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("vatAccountId", vatAccountId); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Create a bill from transactions. /// public Bill CreateFromTransactions(int[] transactions, DateTime creationDate, BillStatus status, DateTime? paidOn = null, int? importId = null) { using var client = new RestClient(parent.url + "api/Transactions/Bill/CreateFrom"); var request = client.RestRequest(Method.Post); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddJsonBody(transactions); request.AddQueryParameter("creationDate", creationDate); request.AddQueryParameter("status", status); request.AddQueryParameter("paidOn", paidOn); request.AddQueryParameter("importId", importId); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } /// /// Update the status of a bill. /// public bool UpdateBill(int billId, BillStatus status, DateTime? paidOn = null) { using var client = new RestClient(parent.url + "api/Transactions/Bill/UpdateStatus"); var request = client.RestRequest(Method.Post); if(parent.Token == null) throw new Exception("Not authorized"); request.AddQueryParameter("token", parent.Token); request.AddQueryParameter("billId", billId); request.AddQueryParameter("status", status); request.AddQueryParameter("paidOn", paidOn); var response = client.Execute(request); if(response.IsSuccessful) return response.Data; else return default; } } /// /// API For the Action History Menu /// public ActionHistory ActionHistory { get; private set; } /// /// API For the Aircraft Log /// public AircraftLogs AircraftLogs { get; private set; } /// /// API For the Aircraft Models /// public AircraftModels AircraftModels { get; private set; } /// /// API For the Aircrafts /// public Aircrafts Aircrafts { get; private set; } /// /// API For the Airports /// public Airports Airports { get; private set; } /// /// API For the Articles /// public Articles Articles { get; private set; } /// /// API For the Authorization /// public Auth Auth { get; private set; } /// /// API to access the backups /// public Backups Backups { get; private set; } /// /// API For the bills /// public Bill Bill { get; private set; } /// /// API For the Calendar /// public Calendar Calendar { get; private set; } /// /// API For the Catalogs /// public Catalogs Catalogs { get; private set; } /// /// API For the Currencies /// public Currencies Currencies { get; private set; } /// /// API For diagnostic purpose /// public Diagnostic Diagnostic { get; private set; } /// /// API For the Documents /// public Documents Documents { get; private set; } /// /// API For the Finances account /// public Finances Finances { get; private set; } /// /// API For the FlightActivityTypes /// public FlightActivityTypes FlightActivityTypes { get; private set; } /// /// API For the Instructions /// public Instructions Instructions { get; private set; } /// /// API For the Instructions Types /// public InstructionTypes InstructionTypes { get; private set; } /// /// API For the home Links /// public Links Links { get; private set; } /// /// API For the MemberMembership /// public MemberMemberships MemberMemberships { get; private set; } /// /// API For the Members /// public Members Members { get; private set; } /// /// API For the Membership /// public Memberships Memberships { get; private set; } /// /// API For the Aircraft Movements /// public Movements Movements { get; private set; } /// /// API For the News /// public News News { get; private set; } /// /// API For the Reservations (not directly used by the Calendar UI) /// public Reservations Reservations { get; private set; } /// /// API For the Reservation Types /// public ReservationTypes ReservationTypes { get; private set; } /// /// API For the Right Types /// public RightTypes RightTypes { get; private set; } /// /// API For the Role Types /// public RoleTypes RoleTypes { get; private set; } /// /// API For the Global Search /// public Search Search { get; private set; } /// /// API For the TechLog /// public TechLog TechLog { get; private set; } /// /// API For the Transactions /// public Transactions Transactions { get; private set; } public API() { ActionHistory = new ActionHistory(this); AircraftLogs = new AircraftLogs(this); AircraftModels = new AircraftModels(this); Aircrafts = new Aircrafts(this); Airports = new Airports(this); Articles = new Articles(this); Auth = new Auth(this); Backups = new Backups(this); Bill = new Bill(this); Calendar = new Calendar(this); Catalogs = new Catalogs(this); Currencies = new Currencies(this); Diagnostic = new Diagnostic(this); Documents = new Documents(this); Finances = new Finances(this); FlightActivityTypes = new FlightActivityTypes(this); Instructions = new Instructions(this); InstructionTypes = new InstructionTypes(this); Links = new Links(this); MemberMemberships = new MemberMemberships(this); Members = new Members(this); Memberships = new Memberships(this); Movements = new Movements(this); News = new News(this); Reservations = new Reservations(this); ReservationTypes = new ReservationTypes(this); RightTypes = new RightTypes(this); RoleTypes = new RoleTypes(this); Search = new Search(this); TechLog = new TechLog(this); Transactions = new Transactions(this); } }