From 4c42cd1d69e491c6eb2875bd15c7b6da811215f7 Mon Sep 17 00:00:00 2001 From: Tearth Date: Sun, 28 Jun 2020 17:09:14 +0200 Subject: [PATCH 01/25] Change API version to v3 --- Oddity/APIConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Oddity/APIConfiguration.cs b/Oddity/APIConfiguration.cs index 8b72425..236b240 100644 --- a/Oddity/APIConfiguration.cs +++ b/Oddity/APIConfiguration.cs @@ -2,7 +2,7 @@ { public class ApiConfiguration { - public const string ApiEndpoint = "https://api.spacexdata.com/v2/"; + public const string ApiEndpoint = "https://api.spacexdata.com/v3/"; public const int DefaultTimeoutSeconds = 5; public const string LibraryName = "Oddity"; From 42514e5ff2336c4ae12835e2a4d9b3a6cf19163e Mon Sep 17 00:00:00 2001 From: Tearth Date: Sun, 28 Jun 2020 17:37:12 +0200 Subject: [PATCH 02/25] Move history to the separate endpoint --- Oddity/API/Builders/{Company => History}/HistoryBuilder.cs | 6 +++--- Oddity/API/Company.cs | 1 + Oddity/API/Models/{Company => History}/EventLinks.cs | 2 +- Oddity/API/Models/{Company => History}/HistoryEvent.cs | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) rename Oddity/API/Builders/{Company => History}/HistoryBuilder.cs (96%) rename Oddity/API/Models/{Company => History}/EventLinks.cs (81%) rename Oddity/API/Models/{Company => History}/HistoryEvent.cs (87%) diff --git a/Oddity/API/Builders/Company/HistoryBuilder.cs b/Oddity/API/Builders/History/HistoryBuilder.cs similarity index 96% rename from Oddity/API/Builders/Company/HistoryBuilder.cs rename to Oddity/API/Builders/History/HistoryBuilder.cs index 6aeed0b..8618238 100644 --- a/Oddity/API/Builders/Company/HistoryBuilder.cs +++ b/Oddity/API/Builders/History/HistoryBuilder.cs @@ -2,16 +2,16 @@ using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; -using Oddity.API.Models.Company; +using Oddity.API.Models.History; -namespace Oddity.API.Builders.Company +namespace Oddity.API.Builders.History { /// /// Represents a set of methods to filter history events and download them from API. /// public class HistoryBuilder : BuilderBase> { - private const string CompanyHistoryEndpoint = "info/history"; + private const string CompanyHistoryEndpoint = "history"; /// /// Initializes a new instance of the class. diff --git a/Oddity/API/Company.cs b/Oddity/API/Company.cs index b985415..3ada87c 100644 --- a/Oddity/API/Company.cs +++ b/Oddity/API/Company.cs @@ -1,6 +1,7 @@ using System.Net.Http; using Oddity.API.Builders; using Oddity.API.Builders.Company; +using Oddity.API.Builders.History; namespace Oddity.API { diff --git a/Oddity/API/Models/Company/EventLinks.cs b/Oddity/API/Models/History/EventLinks.cs similarity index 81% rename from Oddity/API/Models/Company/EventLinks.cs rename to Oddity/API/Models/History/EventLinks.cs index 7821660..59f4db1 100644 --- a/Oddity/API/Models/Company/EventLinks.cs +++ b/Oddity/API/Models/History/EventLinks.cs @@ -1,4 +1,4 @@ -namespace Oddity.API.Models.Company +namespace Oddity.API.Models.History { public class EventLinks { diff --git a/Oddity/API/Models/Company/HistoryEvent.cs b/Oddity/API/Models/History/HistoryEvent.cs similarity index 87% rename from Oddity/API/Models/Company/HistoryEvent.cs rename to Oddity/API/Models/History/HistoryEvent.cs index 7ae2aeb..72c0313 100644 --- a/Oddity/API/Models/Company/HistoryEvent.cs +++ b/Oddity/API/Models/History/HistoryEvent.cs @@ -1,10 +1,11 @@ using System; using Newtonsoft.Json; -namespace Oddity.API.Models.Company +namespace Oddity.API.Models.History { public class HistoryEvent { + public int Id { get; set; } public string Title { get; set; } [JsonProperty("event_date_utc")] From b38af5aee5b6eb434958e7fc3daf5754caab523b Mon Sep 17 00:00:00 2001 From: Tearth Date: Sun, 28 Jun 2020 17:40:53 +0200 Subject: [PATCH 03/25] Add missing data to company info --- Oddity/API/Models/Company/CompanyInfo.cs | 1 + Oddity/API/Models/Company/CompanyLinks.cs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 Oddity/API/Models/Company/CompanyLinks.cs diff --git a/Oddity/API/Models/Company/CompanyInfo.cs b/Oddity/API/Models/Company/CompanyInfo.cs index d9e6ea5..02b91b6 100644 --- a/Oddity/API/Models/Company/CompanyInfo.cs +++ b/Oddity/API/Models/Company/CompanyInfo.cs @@ -28,6 +28,7 @@ public class CompanyInfo public ulong? Valuation { get; set; } public Headquarters Headquarters { get; set; } + public CompanyLinks Links { get; set; } public string Summary { get; set; } } } diff --git a/Oddity/API/Models/Company/CompanyLinks.cs b/Oddity/API/Models/Company/CompanyLinks.cs new file mode 100644 index 0000000..09360e1 --- /dev/null +++ b/Oddity/API/Models/Company/CompanyLinks.cs @@ -0,0 +1,14 @@ +using Newtonsoft.Json; + +namespace Oddity.API.Models.Company +{ + public class CompanyLinks + { + public string Website { get; set; } + public string Flickr { get; set; } + public string Twitter { get; set; } + + [JsonProperty("elon_twitter")] + public string ElonTwitter { get; set; } + } +} From 10f91b29844758622811456a58262533ff2be593 Mon Sep 17 00:00:00 2001 From: Tearth Date: Sun, 28 Jun 2020 23:09:35 +0200 Subject: [PATCH 04/25] Add support for single history events --- Oddity/API/Builders/History/EventBuilder.cs | 50 +++++++++++++++++++++ Oddity/API/Company.cs | 10 ----- Oddity/API/History.cs | 46 +++++++++++++++++++ Oddity/OddityCore.cs | 6 +++ 4 files changed, 102 insertions(+), 10 deletions(-) create mode 100644 Oddity/API/Builders/History/EventBuilder.cs create mode 100644 Oddity/API/History.cs diff --git a/Oddity/API/Builders/History/EventBuilder.cs b/Oddity/API/Builders/History/EventBuilder.cs new file mode 100644 index 0000000..09788cc --- /dev/null +++ b/Oddity/API/Builders/History/EventBuilder.cs @@ -0,0 +1,50 @@ +using System.Net.Http; +using System.Threading.Tasks; +using Oddity.API.Models.DetailedCapsule; +using Oddity.API.Models.History; + +namespace Oddity.API.Builders.History +{ + /// + /// Represents a set of methods to filter history event and download them from API. + /// + public class EventBuilder : BuilderBase + { + private int? _eventId; + private const string CapsuleInfoEndpoint = "history"; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + /// The builder delegates container. + public EventBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + { + + } + + /// + /// Filters history event information by the specified ID. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved capsule serial filter. + /// + /// The history event ID. + /// The history event information. + public EventBuilder WithId(int eventId) + { + _eventId = eventId; + return this; + } + + /// + protected override async Task ExecuteBuilder() + { + var link = BuildLink(CapsuleInfoEndpoint); + if (_eventId != null) + { + link += $"/{_eventId.ToString().ToUpper()}"; + } + + return await SendRequestToApi(link).ConfigureAwait(false); + } + } +} diff --git a/Oddity/API/Company.cs b/Oddity/API/Company.cs index 3ada87c..e329ef5 100644 --- a/Oddity/API/Company.cs +++ b/Oddity/API/Company.cs @@ -33,15 +33,5 @@ public InfoBuilder GetInfo() { return new InfoBuilder(_httpClient, _builderDelegatesContainer); } - - /// - /// Gets company history events. This method returns only builder which doesn't retrieve data from API itself, - /// you should call or to get the data from SpaceX API. - /// - /// The company history events builder. - public HistoryBuilder GetHistory() - { - return new HistoryBuilder(_httpClient, _builderDelegatesContainer); - } } } diff --git a/Oddity/API/History.cs b/Oddity/API/History.cs new file mode 100644 index 0000000..f03b5e1 --- /dev/null +++ b/Oddity/API/History.cs @@ -0,0 +1,46 @@ +using System.Net.Http; +using Oddity.API.Builders; +using Oddity.API.Builders.History; + +namespace Oddity.API +{ + /// + /// Represents a set of methods to get company history. + /// + public class History + { + private readonly HttpClient _httpClient; + private readonly BuilderDelegatesContainer _builderDelegatesContainer; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + /// The builder delegates container. + public History(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) + { + _httpClient = httpClient; + _builderDelegatesContainer = builderDelegatesContainer; + } + + /// + /// Gets company history event. This method returns only builder which doesn't retrieve data from API itself, + /// you should call or to get the data from SpaceX API. + /// + /// The company history events builder. + public EventBuilder GetEvent() + { + return new EventBuilder(_httpClient, _builderDelegatesContainer); + } + + /// + /// Gets company history events. This method returns only builder which doesn't retrieve data from API itself, + /// you should call or to get the data from SpaceX API. + /// + /// The company history events builder. + public HistoryBuilder GetAll() + { + return new HistoryBuilder(_httpClient, _builderDelegatesContainer); + } + } +} diff --git a/Oddity/OddityCore.cs b/Oddity/OddityCore.cs index bb90529..076b637 100644 --- a/Oddity/OddityCore.cs +++ b/Oddity/OddityCore.cs @@ -22,6 +22,11 @@ public class OddityCore : IDisposable /// public Company Company { get; } + /// + /// Gets the company history. + /// + public History History { get; } + /// /// Gets the rockets information. /// @@ -94,6 +99,7 @@ public OddityCore() Api = new Api(_httpClient, builderDelegatesContainer); Company = new Company(_httpClient, builderDelegatesContainer); + History = new History(_httpClient, builderDelegatesContainer); Rockets = new Rockets(_httpClient, builderDelegatesContainer); Capsules = new Capsules(_httpClient, builderDelegatesContainer); DetailedCapsules = new DetailedCapsules(_httpClient, builderDelegatesContainer); From 2ee3f94ce9755b486638eff8e275906fdaadabc1 Mon Sep 17 00:00:00 2001 From: Tearth Date: Sun, 28 Jun 2020 23:40:24 +0200 Subject: [PATCH 05/25] Rename capsules endpoint to Dragons --- .../Builders/Capsules/AllCapsulesBuilder.cs | 32 ------------------- .../AllDetailedCapsulesBuilder.cs | 2 +- .../API/Builders/Dragons/AllDragonsBuilder.cs | 32 +++++++++++++++++++ .../DragonBuilder.cs} | 22 ++++++------- Oddity/API/{Capsules.cs => Dragons.cs} | 24 +++++++------- .../DetailedCapsule/DetailedCapsuleInfo.cs | 2 +- .../CapsuleInfo.cs => Dragon/DragonInfo.cs} | 4 +-- .../CapsuleId.cs => Dragon/DraognId.cs} | 7 ++-- .../Heatshield/HeatshieldInfo.cs | 0 .../{Capsule => Dragon}/Payload/CargoInfo.cs | 0 .../Payload/PressurizedCapsuleInfo.cs | 0 .../{Capsule => Dragon}/Payload/TrunkInfo.cs | 0 .../Thrusters/ThrusterType.cs | 0 .../Thrusters/ThrustersInfo.cs | 0 Oddity/OddityCore.cs | 4 +-- 15 files changed, 63 insertions(+), 66 deletions(-) delete mode 100644 Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs create mode 100644 Oddity/API/Builders/Dragons/AllDragonsBuilder.cs rename Oddity/API/Builders/{Capsules/CapsuleBuilder.cs => Dragons/DragonBuilder.cs} (55%) rename Oddity/API/{Capsules.cs => Dragons.cs} (56%) rename Oddity/API/Models/{Capsule/CapsuleInfo.cs => Dragon/DragonInfo.cs} (95%) rename Oddity/API/Models/{Capsule/CapsuleId.cs => Dragon/DraognId.cs} (64%) rename Oddity/API/Models/{Capsule => Dragon}/Heatshield/HeatshieldInfo.cs (100%) rename Oddity/API/Models/{Capsule => Dragon}/Payload/CargoInfo.cs (100%) rename Oddity/API/Models/{Capsule => Dragon}/Payload/PressurizedCapsuleInfo.cs (100%) rename Oddity/API/Models/{Capsule => Dragon}/Payload/TrunkInfo.cs (100%) rename Oddity/API/Models/{Capsule => Dragon}/Thrusters/ThrusterType.cs (100%) rename Oddity/API/Models/{Capsule => Dragon}/Thrusters/ThrustersInfo.cs (100%) diff --git a/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs b/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs deleted file mode 100644 index e418e55..0000000 --- a/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using Oddity.API.Models.Capsule; - -namespace Oddity.API.Builders.Capsules -{ - /// - /// Represents a set of methods to filter all capsules information and download them from API. - /// - public class AllCapsulesBuilder : BuilderBase> - { - private const string CapsuleInfoEndpoint = "capsules"; - - /// - /// Initializes a new instance of the class. - /// - /// The HTTP client. - /// The builder delegates container. - public AllCapsulesBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) - { - - } - - /// - protected override async Task> ExecuteBuilder() - { - var link = BuildLink(CapsuleInfoEndpoint); - return await SendRequestToApi(link).ConfigureAwait(false); - } - } -} diff --git a/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs b/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs index f14a094..975051a 100644 --- a/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs +++ b/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs @@ -43,7 +43,7 @@ public AllDetailedCapsulesBuilder WithCapsuleSerial(string capsuleSerial) /// /// The capsule id (Dragon 1, Dragon 2 etc). /// The detailed capsules builder. - public AllDetailedCapsulesBuilder WithCapsuleId(CapsuleId capsuleId) + public AllDetailedCapsulesBuilder WithCapsuleId(DraognId capsuleId) { AddFilter("capsule_id", capsuleId.GetEnumMemberAttributeValue(capsuleId)); return this; diff --git a/Oddity/API/Builders/Dragons/AllDragonsBuilder.cs b/Oddity/API/Builders/Dragons/AllDragonsBuilder.cs new file mode 100644 index 0000000..9627749 --- /dev/null +++ b/Oddity/API/Builders/Dragons/AllDragonsBuilder.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Oddity.API.Models.Capsule; + +namespace Oddity.API.Builders.Dragons +{ + /// + /// Represents a set of methods to filter all Dragon types information and download them from API. + /// + public class AllDragonsBuilder : BuilderBase> + { + private const string DragonEndpoint = "dragons"; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + /// The builder delegates container. + public AllDragonsBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + { + + } + + /// + protected override async Task> ExecuteBuilder() + { + var link = BuildLink(DragonEndpoint); + return await SendRequestToApi(link).ConfigureAwait(false); + } + } +} diff --git a/Oddity/API/Builders/Capsules/CapsuleBuilder.cs b/Oddity/API/Builders/Dragons/DragonBuilder.cs similarity index 55% rename from Oddity/API/Builders/Capsules/CapsuleBuilder.cs rename to Oddity/API/Builders/Dragons/DragonBuilder.cs index 88f8b0d..3cf0aeb 100644 --- a/Oddity/API/Builders/Capsules/CapsuleBuilder.cs +++ b/Oddity/API/Builders/Dragons/DragonBuilder.cs @@ -2,42 +2,42 @@ using System.Threading.Tasks; using Oddity.API.Models.Capsule; -namespace Oddity.API.Builders.Capsules +namespace Oddity.API.Builders.Dragons { /// - /// Represents a set of methods to filter capsule information and download them from API. + /// Represents a set of methods to filter Dragon type information and download them from API. /// - public class CapsuleBuilder : BuilderBase + public class DragonBuilder : BuilderBase { - private CapsuleId? _capsuleType; - private const string CapsuleInfoEndpoint = "capsules"; + private DraognId? _capsuleType; + private const string DragonsEndpoint = "dragons"; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The HTTP client. /// The builder delegates container. - public CapsuleBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + public DragonBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) { } /// - /// Filters capsule information by the specified capsule type. Note that you have to call or + /// Filters Dragon type information by the specified capsule type. Note that you have to call or /// to get result from the API. Every next call of this method will override previously saved capsule type filter. /// /// The capsule type (Dragon1, Dragon2, etc). /// The capsule information. - public CapsuleBuilder WithType(CapsuleId type) + public DragonBuilder WithType(DraognId type) { _capsuleType = type; return this; } /// - protected override async Task ExecuteBuilder() + protected override async Task ExecuteBuilder() { - var link = BuildLink(CapsuleInfoEndpoint); + var link = BuildLink(DragonsEndpoint); if (_capsuleType.HasValue) { link += $"/{_capsuleType.ToString().ToLower()}"; diff --git a/Oddity/API/Capsules.cs b/Oddity/API/Dragons.cs similarity index 56% rename from Oddity/API/Capsules.cs rename to Oddity/API/Dragons.cs index be45102..85478c0 100644 --- a/Oddity/API/Capsules.cs +++ b/Oddity/API/Dragons.cs @@ -1,50 +1,50 @@ using System.Net.Http; using Oddity.API.Builders; -using Oddity.API.Builders.Capsules; +using Oddity.API.Builders.Dragons; using Oddity.API.Models.Capsule; namespace Oddity.API { /// - /// Represents a set of methods to get capsules information. + /// Represents a set of methods to get Dragon information. /// - public class Capsules + public class Dragons { private readonly HttpClient _httpClient; private readonly BuilderDelegatesContainer _builderDelegatesContainer; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The HTTP client. /// The builder delegates container. - public Capsules(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) + public Dragons(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) { _httpClient = httpClient; _builderDelegatesContainer = builderDelegatesContainer; } /// - /// Gets information about the specified capsule. This method returns only builder which doesn't retrieve data from API itself, so after apply + /// Gets information about the specified Dragon type. This method returns only builder which doesn't retrieve data from API itself, so after apply /// all necessary filters you should call or to /// get the data from SpaceX API. /// - /// The capsule type. + /// The Dragon type. /// The capsule builder. - public CapsuleBuilder GetAbout(CapsuleId capsuleType) + public DragonBuilder GetAbout(DraognId dragonType) { - return new CapsuleBuilder(_httpClient, _builderDelegatesContainer).WithType(capsuleType); + return new DragonBuilder(_httpClient, _builderDelegatesContainer).WithType(dragonType); } /// - /// Gets information about all capsules. This method returns only builder which doesn't retrieve data from API itself, so after apply + /// Gets information about all Dragon types. This method returns only builder which doesn't retrieve data from API itself, so after apply /// all necessary filters you should call or to /// get the data from SpaceX API. /// /// The all capsules builder. - public AllCapsulesBuilder GetAll() + public AllDragonsBuilder GetAll() { - return new AllCapsulesBuilder(_httpClient, _builderDelegatesContainer); + return new AllDragonsBuilder(_httpClient, _builderDelegatesContainer); } } } diff --git a/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs b/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs index 6e5b102..f3a64ba 100644 --- a/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs +++ b/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs @@ -11,7 +11,7 @@ public class DetailedCapsuleInfo public string CapsuleSerial { get; set; } [JsonProperty("capsule_id")] - public CapsuleId? CapsuleId { get; set; } + public DraognId? CapsuleId { get; set; } public DetailedCapsuleStatus? Status { get; set; } diff --git a/Oddity/API/Models/Capsule/CapsuleInfo.cs b/Oddity/API/Models/Dragon/DragonInfo.cs similarity index 95% rename from Oddity/API/Models/Capsule/CapsuleInfo.cs rename to Oddity/API/Models/Dragon/DragonInfo.cs index 6107c53..72f4dc0 100644 --- a/Oddity/API/Models/Capsule/CapsuleInfo.cs +++ b/Oddity/API/Models/Dragon/DragonInfo.cs @@ -7,9 +7,9 @@ namespace Oddity.API.Models.Capsule { - public class CapsuleInfo + public class DragonInfo { - public CapsuleId? Id { get; set; } + public DraognId? Id { get; set; } public string Name { get; set; } public bool? Active { get; set; } diff --git a/Oddity/API/Models/Capsule/CapsuleId.cs b/Oddity/API/Models/Dragon/DraognId.cs similarity index 64% rename from Oddity/API/Models/Capsule/CapsuleId.cs rename to Oddity/API/Models/Dragon/DraognId.cs index 24bdf4a..8d8887f 100644 --- a/Oddity/API/Models/Capsule/CapsuleId.cs +++ b/Oddity/API/Models/Dragon/DraognId.cs @@ -2,15 +2,12 @@ namespace Oddity.API.Models.Capsule { - public enum CapsuleId + public enum DraognId { [EnumMember(Value = "dragon1")] Dragon1, [EnumMember(Value = "dragon2")] - Dragon2, - - [EnumMember(Value = "crewdragon")] - CrewDragon + Dragon2 } } diff --git a/Oddity/API/Models/Capsule/Heatshield/HeatshieldInfo.cs b/Oddity/API/Models/Dragon/Heatshield/HeatshieldInfo.cs similarity index 100% rename from Oddity/API/Models/Capsule/Heatshield/HeatshieldInfo.cs rename to Oddity/API/Models/Dragon/Heatshield/HeatshieldInfo.cs diff --git a/Oddity/API/Models/Capsule/Payload/CargoInfo.cs b/Oddity/API/Models/Dragon/Payload/CargoInfo.cs similarity index 100% rename from Oddity/API/Models/Capsule/Payload/CargoInfo.cs rename to Oddity/API/Models/Dragon/Payload/CargoInfo.cs diff --git a/Oddity/API/Models/Capsule/Payload/PressurizedCapsuleInfo.cs b/Oddity/API/Models/Dragon/Payload/PressurizedCapsuleInfo.cs similarity index 100% rename from Oddity/API/Models/Capsule/Payload/PressurizedCapsuleInfo.cs rename to Oddity/API/Models/Dragon/Payload/PressurizedCapsuleInfo.cs diff --git a/Oddity/API/Models/Capsule/Payload/TrunkInfo.cs b/Oddity/API/Models/Dragon/Payload/TrunkInfo.cs similarity index 100% rename from Oddity/API/Models/Capsule/Payload/TrunkInfo.cs rename to Oddity/API/Models/Dragon/Payload/TrunkInfo.cs diff --git a/Oddity/API/Models/Capsule/Thrusters/ThrusterType.cs b/Oddity/API/Models/Dragon/Thrusters/ThrusterType.cs similarity index 100% rename from Oddity/API/Models/Capsule/Thrusters/ThrusterType.cs rename to Oddity/API/Models/Dragon/Thrusters/ThrusterType.cs diff --git a/Oddity/API/Models/Capsule/Thrusters/ThrustersInfo.cs b/Oddity/API/Models/Dragon/Thrusters/ThrustersInfo.cs similarity index 100% rename from Oddity/API/Models/Capsule/Thrusters/ThrustersInfo.cs rename to Oddity/API/Models/Dragon/Thrusters/ThrustersInfo.cs diff --git a/Oddity/OddityCore.cs b/Oddity/OddityCore.cs index 076b637..0c4c49f 100644 --- a/Oddity/OddityCore.cs +++ b/Oddity/OddityCore.cs @@ -35,7 +35,7 @@ public class OddityCore : IDisposable /// /// Gets the capsules information. /// - public Capsules Capsules { get; } + public Dragons Dragons { get; } /// /// Gets the detailed capsules information. @@ -101,7 +101,7 @@ public OddityCore() Company = new Company(_httpClient, builderDelegatesContainer); History = new History(_httpClient, builderDelegatesContainer); Rockets = new Rockets(_httpClient, builderDelegatesContainer); - Capsules = new Capsules(_httpClient, builderDelegatesContainer); + Dragons = new Dragons(_httpClient, builderDelegatesContainer); DetailedCapsules = new DetailedCapsules(_httpClient, builderDelegatesContainer); DetailedCores = new DetailedCores(_httpClient, builderDelegatesContainer); Launchpads = new Launchpads(_httpClient, builderDelegatesContainer); From d79996ccb54b7863d5bd423b72026a182f225b17 Mon Sep 17 00:00:00 2001 From: Tearth Date: Sun, 28 Jun 2020 23:51:59 +0200 Subject: [PATCH 06/25] Update Dragon fields --- .../AllDetailedCapsulesBuilder.cs | 2 +- .../API/Builders/Dragons/AllDragonsBuilder.cs | 2 +- Oddity/API/Builders/Dragons/DragonBuilder.cs | 2 +- Oddity/API/Dragons.cs | 2 +- Oddity/API/History.cs | 4 ++-- .../DetailedCapsule/DetailedCapsuleInfo.cs | 2 +- Oddity/API/Models/Dragon/DragonInfo.cs | 20 ++++++++++++++----- Oddity/API/Models/Dragon/DraognId.cs | 2 +- .../Dragon/Heatshield/HeatshieldInfo.cs | 2 +- Oddity/API/Models/Dragon/Payload/CargoInfo.cs | 2 +- .../Dragon/Payload/PressurizedCapsuleInfo.cs | 2 +- Oddity/API/Models/Dragon/Payload/TrunkInfo.cs | 2 +- .../Models/Dragon/Thrusters/ThrusterType.cs | 2 +- .../Models/Dragon/Thrusters/ThrustersInfo.cs | 2 +- 14 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs b/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs index 975051a..56cec59 100644 --- a/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs +++ b/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; -using Oddity.API.Models.Capsule; using Oddity.API.Models.DetailedCapsule; +using Oddity.API.Models.Dragon; using Oddity.Helpers; namespace Oddity.API.Builders.DetailedCapsules diff --git a/Oddity/API/Builders/Dragons/AllDragonsBuilder.cs b/Oddity/API/Builders/Dragons/AllDragonsBuilder.cs index 9627749..d380d41 100644 --- a/Oddity/API/Builders/Dragons/AllDragonsBuilder.cs +++ b/Oddity/API/Builders/Dragons/AllDragonsBuilder.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; -using Oddity.API.Models.Capsule; +using Oddity.API.Models.Dragon; namespace Oddity.API.Builders.Dragons { diff --git a/Oddity/API/Builders/Dragons/DragonBuilder.cs b/Oddity/API/Builders/Dragons/DragonBuilder.cs index 3cf0aeb..d226854 100644 --- a/Oddity/API/Builders/Dragons/DragonBuilder.cs +++ b/Oddity/API/Builders/Dragons/DragonBuilder.cs @@ -1,6 +1,6 @@ using System.Net.Http; using System.Threading.Tasks; -using Oddity.API.Models.Capsule; +using Oddity.API.Models.Dragon; namespace Oddity.API.Builders.Dragons { diff --git a/Oddity/API/Dragons.cs b/Oddity/API/Dragons.cs index 85478c0..fa4b1b2 100644 --- a/Oddity/API/Dragons.cs +++ b/Oddity/API/Dragons.cs @@ -1,7 +1,7 @@ using System.Net.Http; using Oddity.API.Builders; using Oddity.API.Builders.Dragons; -using Oddity.API.Models.Capsule; +using Oddity.API.Models.Dragon; namespace Oddity.API { diff --git a/Oddity/API/History.cs b/Oddity/API/History.cs index f03b5e1..16fe3f1 100644 --- a/Oddity/API/History.cs +++ b/Oddity/API/History.cs @@ -28,9 +28,9 @@ public History(HttpClient httpClient, BuilderDelegatesContainer builderDelegates /// you should call or to get the data from SpaceX API. /// /// The company history events builder. - public EventBuilder GetEvent() + public EventBuilder GetEvent(int eventId) { - return new EventBuilder(_httpClient, _builderDelegatesContainer); + return new EventBuilder(_httpClient, _builderDelegatesContainer).WithId(eventId); } /// diff --git a/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs b/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs index f3a64ba..72cc77c 100644 --- a/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs +++ b/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using Newtonsoft.Json; -using Oddity.API.Models.Capsule; +using Oddity.API.Models.Dragon; namespace Oddity.API.Models.DetailedCapsule { diff --git a/Oddity/API/Models/Dragon/DragonInfo.cs b/Oddity/API/Models/Dragon/DragonInfo.cs index 72f4dc0..95ea646 100644 --- a/Oddity/API/Models/Dragon/DragonInfo.cs +++ b/Oddity/API/Models/Dragon/DragonInfo.cs @@ -1,11 +1,12 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Newtonsoft.Json; -using Oddity.API.Models.Capsule.Heatshield; -using Oddity.API.Models.Capsule.Payload; -using Oddity.API.Models.Capsule.Thrusters; using Oddity.API.Models.Common; +using Oddity.API.Models.Dragon.Heatshield; +using Oddity.API.Models.Dragon.Payload; +using Oddity.API.Models.Dragon.Thrusters; -namespace Oddity.API.Models.Capsule +namespace Oddity.API.Models.Dragon { public class DragonInfo { @@ -23,6 +24,15 @@ public class DragonInfo [JsonProperty("orbit_duration_yr")] public uint? OrbitDurationYears { get; set; } + [JsonProperty("dry_mass_kg")] + public float DryMassKg { get; set; } + + [JsonProperty("dry_mass_lb")] + public float DryMassLb { get; set; } + + [JsonProperty("first_flight")] + public DateTime FirstFlight { get; set; } + [JsonProperty("heat_shield")] public HeatshieldInfo Heatshield { get; set; } diff --git a/Oddity/API/Models/Dragon/DraognId.cs b/Oddity/API/Models/Dragon/DraognId.cs index 8d8887f..c2486bb 100644 --- a/Oddity/API/Models/Dragon/DraognId.cs +++ b/Oddity/API/Models/Dragon/DraognId.cs @@ -1,6 +1,6 @@ using System.Runtime.Serialization; -namespace Oddity.API.Models.Capsule +namespace Oddity.API.Models.Dragon { public enum DraognId { diff --git a/Oddity/API/Models/Dragon/Heatshield/HeatshieldInfo.cs b/Oddity/API/Models/Dragon/Heatshield/HeatshieldInfo.cs index cac98aa..c238850 100644 --- a/Oddity/API/Models/Dragon/Heatshield/HeatshieldInfo.cs +++ b/Oddity/API/Models/Dragon/Heatshield/HeatshieldInfo.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Oddity.API.Models.Capsule.Heatshield +namespace Oddity.API.Models.Dragon.Heatshield { public class HeatshieldInfo { diff --git a/Oddity/API/Models/Dragon/Payload/CargoInfo.cs b/Oddity/API/Models/Dragon/Payload/CargoInfo.cs index 633bf89..8085075 100644 --- a/Oddity/API/Models/Dragon/Payload/CargoInfo.cs +++ b/Oddity/API/Models/Dragon/Payload/CargoInfo.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Oddity.API.Models.Capsule.Payload +namespace Oddity.API.Models.Dragon.Payload { public class CargoInfo { diff --git a/Oddity/API/Models/Dragon/Payload/PressurizedCapsuleInfo.cs b/Oddity/API/Models/Dragon/Payload/PressurizedCapsuleInfo.cs index 5525383..152fc24 100644 --- a/Oddity/API/Models/Dragon/Payload/PressurizedCapsuleInfo.cs +++ b/Oddity/API/Models/Dragon/Payload/PressurizedCapsuleInfo.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using Oddity.API.Models.Common; -namespace Oddity.API.Models.Capsule.Payload +namespace Oddity.API.Models.Dragon.Payload { public class PressurizedCapsuleInfo { diff --git a/Oddity/API/Models/Dragon/Payload/TrunkInfo.cs b/Oddity/API/Models/Dragon/Payload/TrunkInfo.cs index decc1ec..951a5a4 100644 --- a/Oddity/API/Models/Dragon/Payload/TrunkInfo.cs +++ b/Oddity/API/Models/Dragon/Payload/TrunkInfo.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using Oddity.API.Models.Common; -namespace Oddity.API.Models.Capsule.Payload +namespace Oddity.API.Models.Dragon.Payload { public class TrunkInfo { diff --git a/Oddity/API/Models/Dragon/Thrusters/ThrusterType.cs b/Oddity/API/Models/Dragon/Thrusters/ThrusterType.cs index 35dd905..7c3c376 100644 --- a/Oddity/API/Models/Dragon/Thrusters/ThrusterType.cs +++ b/Oddity/API/Models/Dragon/Thrusters/ThrusterType.cs @@ -1,4 +1,4 @@ -namespace Oddity.API.Models.Capsule.Thrusters +namespace Oddity.API.Models.Dragon.Thrusters { public enum ThrusterType { diff --git a/Oddity/API/Models/Dragon/Thrusters/ThrustersInfo.cs b/Oddity/API/Models/Dragon/Thrusters/ThrustersInfo.cs index 2d0782a..2ee93d2 100644 --- a/Oddity/API/Models/Dragon/Thrusters/ThrustersInfo.cs +++ b/Oddity/API/Models/Dragon/Thrusters/ThrustersInfo.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using Oddity.API.Models.Common; -namespace Oddity.API.Models.Capsule.Thrusters +namespace Oddity.API.Models.Dragon.Thrusters { public class ThrustersInfo { From d6fb405b8f7aa2bbd7b24ff4e1fa13e19836aef9 Mon Sep 17 00:00:00 2001 From: Tearth Date: Sun, 28 Jun 2020 23:54:20 +0200 Subject: [PATCH 07/25] Fix typo --- .../Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs | 2 +- Oddity/API/Builders/Dragons/DragonBuilder.cs | 4 ++-- Oddity/API/Dragons.cs | 2 +- Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs | 2 +- Oddity/API/Models/Dragon/{DraognId.cs => DragonId.cs} | 2 +- Oddity/API/Models/Dragon/DragonInfo.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename Oddity/API/Models/Dragon/{DraognId.cs => DragonId.cs} (89%) diff --git a/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs b/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs index 56cec59..2ff487b 100644 --- a/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs +++ b/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs @@ -43,7 +43,7 @@ public AllDetailedCapsulesBuilder WithCapsuleSerial(string capsuleSerial) /// /// The capsule id (Dragon 1, Dragon 2 etc). /// The detailed capsules builder. - public AllDetailedCapsulesBuilder WithCapsuleId(DraognId capsuleId) + public AllDetailedCapsulesBuilder WithCapsuleId(DragonId capsuleId) { AddFilter("capsule_id", capsuleId.GetEnumMemberAttributeValue(capsuleId)); return this; diff --git a/Oddity/API/Builders/Dragons/DragonBuilder.cs b/Oddity/API/Builders/Dragons/DragonBuilder.cs index d226854..cc5ecaf 100644 --- a/Oddity/API/Builders/Dragons/DragonBuilder.cs +++ b/Oddity/API/Builders/Dragons/DragonBuilder.cs @@ -9,7 +9,7 @@ namespace Oddity.API.Builders.Dragons /// public class DragonBuilder : BuilderBase { - private DraognId? _capsuleType; + private DragonId? _capsuleType; private const string DragonsEndpoint = "dragons"; /// @@ -28,7 +28,7 @@ public DragonBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDel /// /// The capsule type (Dragon1, Dragon2, etc). /// The capsule information. - public DragonBuilder WithType(DraognId type) + public DragonBuilder WithType(DragonId type) { _capsuleType = type; return this; diff --git a/Oddity/API/Dragons.cs b/Oddity/API/Dragons.cs index fa4b1b2..ca278de 100644 --- a/Oddity/API/Dragons.cs +++ b/Oddity/API/Dragons.cs @@ -31,7 +31,7 @@ public Dragons(HttpClient httpClient, BuilderDelegatesContainer builderDelegates /// /// The Dragon type. /// The capsule builder. - public DragonBuilder GetAbout(DraognId dragonType) + public DragonBuilder GetAbout(DragonId dragonType) { return new DragonBuilder(_httpClient, _builderDelegatesContainer).WithType(dragonType); } diff --git a/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs b/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs index 72cc77c..ba976f4 100644 --- a/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs +++ b/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs @@ -11,7 +11,7 @@ public class DetailedCapsuleInfo public string CapsuleSerial { get; set; } [JsonProperty("capsule_id")] - public DraognId? CapsuleId { get; set; } + public DragonId? CapsuleId { get; set; } public DetailedCapsuleStatus? Status { get; set; } diff --git a/Oddity/API/Models/Dragon/DraognId.cs b/Oddity/API/Models/Dragon/DragonId.cs similarity index 89% rename from Oddity/API/Models/Dragon/DraognId.cs rename to Oddity/API/Models/Dragon/DragonId.cs index c2486bb..74cbd1b 100644 --- a/Oddity/API/Models/Dragon/DraognId.cs +++ b/Oddity/API/Models/Dragon/DragonId.cs @@ -2,7 +2,7 @@ namespace Oddity.API.Models.Dragon { - public enum DraognId + public enum DragonId { [EnumMember(Value = "dragon1")] Dragon1, diff --git a/Oddity/API/Models/Dragon/DragonInfo.cs b/Oddity/API/Models/Dragon/DragonInfo.cs index 95ea646..895a026 100644 --- a/Oddity/API/Models/Dragon/DragonInfo.cs +++ b/Oddity/API/Models/Dragon/DragonInfo.cs @@ -10,7 +10,7 @@ namespace Oddity.API.Models.Dragon { public class DragonInfo { - public DraognId? Id { get; set; } + public DragonId? Id { get; set; } public string Name { get; set; } public bool? Active { get; set; } From 0d6a749edbacd12ac90098665afeb70324c4141a Mon Sep 17 00:00:00 2001 From: Tearth Date: Mon, 29 Jun 2020 00:35:36 +0200 Subject: [PATCH 08/25] Update fields in launches --- .../Builders/Launches/AllLaunchesBuilder.cs | 2 +- .../Builders/Launches/LatestLaunchBuilder.cs | 4 +- Oddity/API/Builders/Launches/LaunchBuilder.cs | 49 +++++++++++++++++++ .../Builders/Launches/NextLaunchBuilder.cs | 4 +- .../Builders/Launches/PastLaunchesBuilder.cs | 4 +- .../Launches/UpcomingLaunchesBuilder.cs | 4 +- Oddity/API/Launches.cs | 11 +++++ Oddity/API/Models/Launch/LaunchInfo.cs | 23 +++++++-- Oddity/API/Models/Launch/LinksInfo.cs | 9 +++- Oddity/API/Models/Launch/ReuseInfo.cs | 18 ------- .../Rocket/Fairings/FairingsRecoveryInfo.cs | 15 ++++++ .../Launch/Rocket/FirstStage/CoreInfo.cs | 5 ++ Oddity/API/Models/Launch/Rocket/RocketInfo.cs | 3 ++ .../SecondStage/Orbit/OrbitParameters.cs | 17 ++++++- .../Launch/Rocket/SecondStage/PayloadInfo.cs | 3 ++ .../Rocket/SecondStage/SecondStageInfo.cs | 1 + 16 files changed, 140 insertions(+), 32 deletions(-) create mode 100644 Oddity/API/Builders/Launches/LaunchBuilder.cs delete mode 100644 Oddity/API/Models/Launch/ReuseInfo.cs create mode 100644 Oddity/API/Models/Launch/Rocket/Fairings/FairingsRecoveryInfo.cs diff --git a/Oddity/API/Builders/Launches/AllLaunchesBuilder.cs b/Oddity/API/Builders/Launches/AllLaunchesBuilder.cs index d07cda0..203a874 100644 --- a/Oddity/API/Builders/Launches/AllLaunchesBuilder.cs +++ b/Oddity/API/Builders/Launches/AllLaunchesBuilder.cs @@ -10,7 +10,7 @@ namespace Oddity.API.Builders.Launches /// public class AllLaunchesBuilder : LaunchBuilderBase> { - private const string LaunchpadInfoEndpoint = "launches/all"; + private const string LaunchpadInfoEndpoint = "launches"; /// /// Initializes a new instance of the class. diff --git a/Oddity/API/Builders/Launches/LatestLaunchBuilder.cs b/Oddity/API/Builders/Launches/LatestLaunchBuilder.cs index 334de42..46796d5 100644 --- a/Oddity/API/Builders/Launches/LatestLaunchBuilder.cs +++ b/Oddity/API/Builders/Launches/LatestLaunchBuilder.cs @@ -9,7 +9,7 @@ namespace Oddity.API.Builders.Launches /// public class LatestLaunchesBuilder : BuilderBase { - private const string LaunchpadInfoEndpoint = "launches/latest"; + private const string LaunchesEndpoint = "launches/latest"; /// /// Initializes a new instance of the class. @@ -24,7 +24,7 @@ public LatestLaunchesBuilder(HttpClient httpClient, BuilderDelegatesContainer bu /// protected override async Task ExecuteBuilder() { - var link = BuildLink(LaunchpadInfoEndpoint); + var link = BuildLink(LaunchesEndpoint); return await SendRequestToApi(link).ConfigureAwait(false); } } diff --git a/Oddity/API/Builders/Launches/LaunchBuilder.cs b/Oddity/API/Builders/Launches/LaunchBuilder.cs new file mode 100644 index 0000000..5d75f70 --- /dev/null +++ b/Oddity/API/Builders/Launches/LaunchBuilder.cs @@ -0,0 +1,49 @@ +using System.Net.Http; +using System.Threading.Tasks; +using Oddity.API.Models.Launch; + +namespace Oddity.API.Builders.Launches +{ + /// + /// Represents a set of methods to get the specified launch information and download them from API. + /// + public class LaunchBuilder : BuilderBase + { + private int? _launchId; + private const string LaunchesEndpoint = "launches"; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + /// The builder delegates container. + public LaunchBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + { + + } + + /// + /// Filters launch information by the specified ID. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved capsule serial filter. + /// + /// The launch ID. + /// The launch information. + public LaunchBuilder WithId(int launchId) + { + _launchId = launchId; + return this; + } + + /// + protected override async Task ExecuteBuilder() + { + var link = BuildLink(LaunchesEndpoint); + if (_launchId != null) + { + link += $"/{_launchId.ToString().ToUpper()}"; + } + + return await SendRequestToApi(link).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/Oddity/API/Builders/Launches/NextLaunchBuilder.cs b/Oddity/API/Builders/Launches/NextLaunchBuilder.cs index 85ab3f6..14d2e35 100644 --- a/Oddity/API/Builders/Launches/NextLaunchBuilder.cs +++ b/Oddity/API/Builders/Launches/NextLaunchBuilder.cs @@ -9,7 +9,7 @@ namespace Oddity.API.Builders.Launches /// public class NextLaunchesBuilder : BuilderBase { - private const string LaunchpadInfoEndpoint = "launches/next"; + private const string LaunchesEndpoint = "launches/next"; /// /// Initializes a new instance of the class. @@ -24,7 +24,7 @@ public NextLaunchesBuilder(HttpClient httpClient, BuilderDelegatesContainer buil /// protected override async Task ExecuteBuilder() { - var link = BuildLink(LaunchpadInfoEndpoint); + var link = BuildLink(LaunchesEndpoint); return await SendRequestToApi(link).ConfigureAwait(false); } } diff --git a/Oddity/API/Builders/Launches/PastLaunchesBuilder.cs b/Oddity/API/Builders/Launches/PastLaunchesBuilder.cs index af903e5..fff125e 100644 --- a/Oddity/API/Builders/Launches/PastLaunchesBuilder.cs +++ b/Oddity/API/Builders/Launches/PastLaunchesBuilder.cs @@ -10,7 +10,7 @@ namespace Oddity.API.Builders.Launches /// public class PastLaunchesBuilder : LaunchBuilderBase> { - private const string LaunchpadInfoEndpoint = "launches"; + private const string LaunchesEndpoint = "launches"; /// /// Initializes a new instance of the class. @@ -25,7 +25,7 @@ public PastLaunchesBuilder(HttpClient httpClient, BuilderDelegatesContainer buil /// protected override async Task> ExecuteBuilder() { - var link = BuildLink(LaunchpadInfoEndpoint); + var link = BuildLink(LaunchesEndpoint); return await SendRequestToApi(link).ConfigureAwait(false); } } diff --git a/Oddity/API/Builders/Launches/UpcomingLaunchesBuilder.cs b/Oddity/API/Builders/Launches/UpcomingLaunchesBuilder.cs index becb2e5..9cf837f 100644 --- a/Oddity/API/Builders/Launches/UpcomingLaunchesBuilder.cs +++ b/Oddity/API/Builders/Launches/UpcomingLaunchesBuilder.cs @@ -10,7 +10,7 @@ namespace Oddity.API.Builders.Launches /// public class UpcomingLaunchesBuilder : LaunchBuilderBase> { - private const string LaunchpadInfoEndpoint = "launches/upcoming"; + private const string LaunchesEndpoint = "launches/upcoming"; /// /// Initializes a new instance of the class. @@ -25,7 +25,7 @@ public UpcomingLaunchesBuilder(HttpClient httpClient, BuilderDelegatesContainer /// protected override async Task> ExecuteBuilder() { - var link = BuildLink(LaunchpadInfoEndpoint); + var link = BuildLink(LaunchesEndpoint); return await SendRequestToApi(link).ConfigureAwait(false); } } diff --git a/Oddity/API/Launches.cs b/Oddity/API/Launches.cs index bc8f994..54aab8b 100644 --- a/Oddity/API/Launches.cs +++ b/Oddity/API/Launches.cs @@ -23,6 +23,17 @@ public Launches(HttpClient httpClient, BuilderDelegatesContainer builderDelegate _builderDelegatesContainer = builderDelegatesContainer; } + /// + /// Gets information about the specified launch. This method returns only builder which doesn't retrieve data from API itself, so after apply + /// all necessary filters you should call or to + /// get the data from SpaceX API. + /// + /// The launch builder. + public LaunchBuilder Get(int launchId) + { + return new LaunchBuilder(_httpClient, _builderDelegatesContainer).WithId(launchId); + } + /// /// Gets information about all launches (past and upcoming). This method returns only builder which doesn't retrieve data from API itself, so after apply /// all necessary filters you should call or to diff --git a/Oddity/API/Models/Launch/LaunchInfo.cs b/Oddity/API/Models/Launch/LaunchInfo.cs index 6d36b1f..9ab013c 100644 --- a/Oddity/API/Models/Launch/LaunchInfo.cs +++ b/Oddity/API/Models/Launch/LaunchInfo.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Newtonsoft.Json; using Oddity.API.Models.Launch.Rocket; @@ -12,7 +13,8 @@ public class LaunchInfo [JsonProperty("mission_name")] public string MissionName { get; set; } - public bool? Upcoming { get; set; } + [JsonProperty("mission_id")] + public List MissionId { get; set; } [JsonProperty("launch_year")] public uint? LaunchYear { get; set; } @@ -27,13 +29,22 @@ public class LaunchInfo public DateTime? LaunchDateLocal { get; set; } [JsonProperty("is_tentative")] - public bool IsTentative { get; set; } + public bool? IsTentative { get; set; } [JsonProperty("tentative_max_precision")] public TentativeMaxPrecision? TentativeMaxPrecision { get; set; } + [JsonProperty("tbd")] + public bool? ToBeDated { get; set; } + + [JsonProperty("launch_window")] + public int? LaunchWindow { get; set; } + public RocketInfo Rocket { get; set; } - public ReuseInfo Reuse { get; set; } + + [JsonProperty("ships")] + public List Ships { get; set; } + public TelemetryInfo Telemetry { get; set; } [JsonProperty("launch_site")] @@ -44,8 +55,14 @@ public class LaunchInfo public LinksInfo Links { get; set; } public string Details { get; set; } + public bool? Upcoming { get; set; } [JsonProperty("static_fire_date_utc")] public DateTime? StaticFireDateUtc { get; set; } + + [JsonProperty("static_fire_date_unix")] + public ulong? StaticFireDateUnix { get; set; } + + public Dictionary Timeline { get; set; } } } diff --git a/Oddity/API/Models/Launch/LinksInfo.cs b/Oddity/API/Models/Launch/LinksInfo.cs index 9cdd569..490abb7 100644 --- a/Oddity/API/Models/Launch/LinksInfo.cs +++ b/Oddity/API/Models/Launch/LinksInfo.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace Oddity.API.Models.Launch { @@ -31,5 +32,11 @@ public class LinksInfo [JsonProperty("video_link")] public string VideoLink { get; set; } + + [JsonProperty("youtube_id")] + public string YoutubeId { get; set; } + + [JsonProperty("flickr_images")] + public List FlickrImages { get; set; } } } diff --git a/Oddity/API/Models/Launch/ReuseInfo.cs b/Oddity/API/Models/Launch/ReuseInfo.cs deleted file mode 100644 index f41a31e..0000000 --- a/Oddity/API/Models/Launch/ReuseInfo.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; - -namespace Oddity.API.Models.Launch -{ - public class ReuseInfo - { - public bool? Core { get; set; } - - [JsonProperty("side_core1")] - public bool? FirstSideCore { get; set; } - - [JsonProperty("side_core2")] - public bool? SecondSideCore { get; set; } - - public bool? Fairings { get; set; } - public bool? Capsule { get; set; } - } -} diff --git a/Oddity/API/Models/Launch/Rocket/Fairings/FairingsRecoveryInfo.cs b/Oddity/API/Models/Launch/Rocket/Fairings/FairingsRecoveryInfo.cs new file mode 100644 index 0000000..0e68534 --- /dev/null +++ b/Oddity/API/Models/Launch/Rocket/Fairings/FairingsRecoveryInfo.cs @@ -0,0 +1,15 @@ +using Newtonsoft.Json; + +namespace Oddity.API.Models.Launch.Rocket.Fairings +{ + public class FairingsRecoveryInfo + { + public bool? Reused { get; set; } + + [JsonProperty("recovery_attempt")] + public bool? RecoveryAttempt { get; set; } + + public bool? Recovered { get; set; } + public string Ship { get; set; } + } +} diff --git a/Oddity/API/Models/Launch/Rocket/FirstStage/CoreInfo.cs b/Oddity/API/Models/Launch/Rocket/FirstStage/CoreInfo.cs index fd7631c..191df8c 100644 --- a/Oddity/API/Models/Launch/Rocket/FirstStage/CoreInfo.cs +++ b/Oddity/API/Models/Launch/Rocket/FirstStage/CoreInfo.cs @@ -9,11 +9,16 @@ public class CoreInfo public uint? Flight { get; set; } public uint? Block { get; set; } + public bool? GridFins { get; set; } + public bool? Legs { get; set; } public bool? Reused { get; set; } [JsonProperty("land_success")] public bool? LandSuccess { get; set; } + [JsonProperty("landing_intent")] + public bool? LandingIntent { get; set; } + [JsonProperty("landing_type")] public LandingType? LandingType { get; set; } diff --git a/Oddity/API/Models/Launch/Rocket/RocketInfo.cs b/Oddity/API/Models/Launch/Rocket/RocketInfo.cs index 38b3372..3055fcf 100644 --- a/Oddity/API/Models/Launch/Rocket/RocketInfo.cs +++ b/Oddity/API/Models/Launch/Rocket/RocketInfo.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using Oddity.API.Models.Launch.Rocket.Fairings; using Oddity.API.Models.Launch.Rocket.FirstStage; using Oddity.API.Models.Launch.Rocket.SecondStage; using Oddity.API.Models.Rocket; @@ -21,5 +22,7 @@ public class RocketInfo [JsonProperty("second_stage")] public SecondStageInfo SecondStage { get; set; } + + public FairingsRecoveryInfo Fairings { get; set; } } } diff --git a/Oddity/API/Models/Launch/Rocket/SecondStage/Orbit/OrbitParameters.cs b/Oddity/API/Models/Launch/Rocket/SecondStage/Orbit/OrbitParameters.cs index f114b29..db8dab6 100644 --- a/Oddity/API/Models/Launch/Rocket/SecondStage/Orbit/OrbitParameters.cs +++ b/Oddity/API/Models/Launch/Rocket/SecondStage/Orbit/OrbitParameters.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System; +using Newtonsoft.Json; namespace Oddity.API.Models.Launch.Rocket.SecondStage.Orbit { @@ -29,5 +30,19 @@ public class OrbitParameters [JsonProperty("lifespan_years")] public float? LifespanYears { get; set; } + + public DateTime? Epoch { get; set; } + + [JsonProperty("mean_motion")] + public float? MeanMotion { get; set; } + + [JsonProperty("raan")] + public float? Raan { get; set; } + + [JsonProperty("arg_of_pericenter")] + public float? ArgOfPericenter { get; set; } + + [JsonProperty("mean_anomaly")] + public float? MeanAnomaly { get; set; } } } diff --git a/Oddity/API/Models/Launch/Rocket/SecondStage/PayloadInfo.cs b/Oddity/API/Models/Launch/Rocket/SecondStage/PayloadInfo.cs index ff8a639..75491b8 100644 --- a/Oddity/API/Models/Launch/Rocket/SecondStage/PayloadInfo.cs +++ b/Oddity/API/Models/Launch/Rocket/SecondStage/PayloadInfo.cs @@ -9,6 +9,9 @@ public class PayloadInfo [JsonProperty("payload_id")] public string PayloadId { get; set; } + [JsonProperty("norad_id")] + public List NoradId { get; set; } + public bool? Reused { get; set; } public List Customers { get; set; } public string Nationality { get; set; } diff --git a/Oddity/API/Models/Launch/Rocket/SecondStage/SecondStageInfo.cs b/Oddity/API/Models/Launch/Rocket/SecondStage/SecondStageInfo.cs index 938402b..320c390 100644 --- a/Oddity/API/Models/Launch/Rocket/SecondStage/SecondStageInfo.cs +++ b/Oddity/API/Models/Launch/Rocket/SecondStage/SecondStageInfo.cs @@ -4,6 +4,7 @@ namespace Oddity.API.Models.Launch.Rocket.SecondStage { public class SecondStageInfo { + public int? Block { get; set; } public List Payloads { get; set; } } } From 1a76d58bbaffc31fbe9da02f5c2863b506036462 Mon Sep 17 00:00:00 2001 From: Tearth Date: Mon, 29 Jun 2020 00:36:44 +0200 Subject: [PATCH 09/25] Fix typo --- Oddity/API/Models/Dragon/DragonInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Oddity/API/Models/Dragon/DragonInfo.cs b/Oddity/API/Models/Dragon/DragonInfo.cs index 895a026..daba27a 100644 --- a/Oddity/API/Models/Dragon/DragonInfo.cs +++ b/Oddity/API/Models/Dragon/DragonInfo.cs @@ -25,10 +25,10 @@ public class DragonInfo public uint? OrbitDurationYears { get; set; } [JsonProperty("dry_mass_kg")] - public float DryMassKg { get; set; } + public float DryMassKilograms { get; set; } [JsonProperty("dry_mass_lb")] - public float DryMassLb { get; set; } + public float DryMassPounds { get; set; } [JsonProperty("first_flight")] public DateTime FirstFlight { get; set; } From 0f2d8c8d41319720ecc27af9638436b2fa1eed47 Mon Sep 17 00:00:00 2001 From: Tearth Date: Mon, 29 Jun 2020 18:10:12 +0200 Subject: [PATCH 10/25] Add missing filters to launch builder --- Oddity/API/Builders/BuilderBase.cs | 21 ++ .../Builders/Launches/LaunchBuilderBase.cs | 353 +++++++++++++++--- 2 files changed, 324 insertions(+), 50 deletions(-) diff --git a/Oddity/API/Builders/BuilderBase.cs b/Oddity/API/Builders/BuilderBase.cs index 731cb31..e6d21af 100644 --- a/Oddity/API/Builders/BuilderBase.cs +++ b/Oddity/API/Builders/BuilderBase.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Net; using System.Net.Http; using System.Text; @@ -74,6 +75,16 @@ protected void AddFilter(string name, int value) _filters[name] = value.ToString(); } + /// + /// Adds or overrides filter with the specified name and double value. + /// + /// The filter name. + /// The filter double value. + protected void AddFilter(string name, double value) + { + _filters[name] = value.ToString(CultureInfo.InvariantCulture); + } + /// /// Adds or overrides filter with the specified name and string value. /// @@ -94,6 +105,16 @@ protected void AddFilter(string name, bool value) _filters[name] = value.ToString().ToLower(); } + /// + /// Adds or overrides filter with the specified name and date value. + /// + /// The filter name. + /// The filter date value. + protected void AddFilter(string name, DateTime value) + { + _filters[name] = value.ToString("O"); + } + /// /// Adds or overrides filter with the specified name and DateTime value. /// diff --git a/Oddity/API/Builders/Launches/LaunchBuilderBase.cs b/Oddity/API/Builders/Launches/LaunchBuilderBase.cs index 632ffc7..f448bcb 100644 --- a/Oddity/API/Builders/Launches/LaunchBuilderBase.cs +++ b/Oddity/API/Builders/Launches/LaunchBuilderBase.cs @@ -97,6 +97,30 @@ public TBuilder WithLaunchDateUtc(DateTime launchDateUtc) return (TBuilder)this; } + /// + /// Filters launches by local launch date. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved launch date filter. + /// + /// The local launch date. + /// The launch builder. + public TBuilder WithLaunchDateLocal(DateTime launchDateLocal) + { + AddFilter("launch_date_local", launchDateLocal, DateFormatType.Long); + return (TBuilder)this; + } + + /// + /// Filters launches by "to be dated" flag. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved rocket id filter. + /// + /// "To be dated" flag. + /// The launch builder. + public TBuilder WithToBeDated(bool toBeDated) + { + AddFilter("tbd", toBeDated); + return (TBuilder)this; + } + /// /// Filters launches by rocket id. Note that you have to call or /// to get result from the API. Every next call of this method will override previously saved rocket id filter. @@ -145,6 +169,55 @@ public TBuilder WithCoreSerial(string coreSerial) return (TBuilder)this; } + /// + /// Filters launches by a landing success. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved core serial filter. + /// + /// Land success flag. + /// The launch builder. + public TBuilder WithLandSuccess(bool landSuccess) + { + AddFilter("land_success", landSuccess); + return (TBuilder)this; + } + + /// + /// Filters launches by landing intention. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved core serial filter. + /// + /// Landing intention flag. + /// The launch builder. + public TBuilder WithLandingIntent(bool landingIntent) + { + AddFilter("landing_intent", landingIntent); + return (TBuilder)this; + } + + + /// + /// Filters launches by landing type. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved landing type filter. + /// + /// The landing type (ASDS, Ocean, etc). + /// The launch builder. + public TBuilder WithLandingType(LandingType landingType) + { + AddFilter("landing_type", landingType.GetEnumMemberAttributeValue(landingType)); + return (TBuilder)this; + } + + /// + /// Filters launches by landing vehicle. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved landing vehicle filter. + /// + /// The landing vehicle (OCISLY, LZ1, etc). + /// The launch builder. + public TBuilder WithLandingVehicle(LandingVehicleType landingVehicle) + { + AddFilter("landing_vehicle", landingVehicle.GetEnumMemberAttributeValue(landingVehicle)); + return (TBuilder)this; + } + /// /// Filters launches by capsule serial. Note that you have to call or /// to get result from the API. Every next call of this method will override previously saved capsule serial filter. @@ -181,6 +254,30 @@ public TBuilder WithBlockNumber(int blockNumber) return (TBuilder)this; } + /// + /// Filters launches by grid fins presence. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved block number filter. + /// + /// Grid fins presence flag. + /// The launch builder. + public TBuilder WithGridFins(bool gridFins) + { + AddFilter("gridfins", gridFins); + return (TBuilder)this; + } + + /// + /// Filters launches by legs presence. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved block number filter. + /// + /// Legs presence flag. + /// The launch builder. + public TBuilder WithLegs(bool legs) + { + AddFilter("legs", legs); + return (TBuilder)this; + } + /// /// Filters launches by core reuse. Note that you have to call or /// to get result from the API. Every next call of this method will override previously saved core reuse filter. @@ -194,50 +291,62 @@ public TBuilder WithCoreReuse(bool coreReuse) } /// - /// Filters launches by first side core reuse. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved first side core reuse filter. + /// Filters launches by capsule reuse. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved capsule reuse filter. /// - /// The first side core reuse. + /// The capsule reuse. /// The launch builder. - public TBuilder WithSideCore1Reuse(bool sideCore1Reuse) + public TBuilder WithCapsuleReuse(bool capsuleReuse) { - AddFilter("side_core1_reuse", sideCore1Reuse); + AddFilter("capsule_reuse", capsuleReuse); return (TBuilder)this; } /// - /// Filters launches by second core reuse. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved second core reuse filter. + /// Filters launches by fairings reuse. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved fairings reuse filter. /// - /// The second side core reuse. + /// The fairings reuse. /// The launch builder. - public TBuilder WithSideCore2Reuse(bool sideCore2Reuse) + public TBuilder WithFairingsReuse(bool fairingsReuse) { - AddFilter("side_core2_reuse", sideCore2Reuse); + AddFilter("fairings_reused", fairingsReuse); return (TBuilder)this; } /// - /// Filters launches by fairings reuse. Note that you have to call or + /// Filters launches by fairings recovery attempt. Note that you have to call or /// to get result from the API. Every next call of this method will override previously saved fairings reuse filter. /// - /// The fairings reuse. + /// Fairings recovery attempt flag. /// The launch builder. - public TBuilder WithFairingsReuse(bool fairingsReuse) + public TBuilder WithFairingsRecoveryAttempt(bool fairingsRecoveryAttempt) { - AddFilter("fairings_reuse", fairingsReuse); + AddFilter("fairings_recovery_attempt", fairingsRecoveryAttempt); return (TBuilder)this; } /// - /// Filters launches by capsule reuse. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved capsule reuse filter. + /// Filters launches by fairings recovery result. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved fairings reuse filter. /// - /// The capsule reuse. + /// Fairings recovery status flag. /// The launch builder. - public TBuilder WithCapsuleReuse(bool capsuleReuse) + public TBuilder WithFairingsRecovered(bool fairingsRecovered) { - AddFilter("capsule_reuse", capsuleReuse); + AddFilter("fairings_recovered", fairingsRecovered); + return (TBuilder)this; + } + + /// + /// Filters launches by fairings ship name. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved fairings reuse filter. + /// + /// Fairings ship name. + /// The launch builder. + public TBuilder WithFairingsShip(string fairingsShip) + { + AddFilter("fairings_ship", fairingsShip); return (TBuilder)this; } @@ -264,28 +373,28 @@ public TBuilder WithSiteName(string siteName) AddFilter("site_name", siteName); return (TBuilder)this; } - + /// - /// Filters launches by long site name. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved long site name filter. + /// Filters launches by payload id. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved payload id filter. /// - /// The long launchpad name (Kennedy Space Center Historic Launch Complex 39A, etc). + /// The payload ID (RatSat, Iridium NEXT 2, etc). /// The launch builder. - public TBuilder WithLongSiteName(string longSiteName) + public TBuilder WithPayloadId(string payloadId) { - AddFilter("site_name_long", longSiteName); + AddFilter("payload_id", payloadId); return (TBuilder)this; } /// - /// Filters launches by payload id. Note that you have to call or + /// Filters launches by payload's NORAD ID. Note that you have to call or /// to get result from the API. Every next call of this method will override previously saved payload id filter. /// - /// The payload ID (RatSat, Iridium NEXT 2, etc). + /// The payload NORAD ID. /// The launch builder. - public TBuilder WithPayloadId(string payloadId) + public TBuilder WithNoradId(int noradId) { - AddFilter("payload_id", payloadId); + AddFilter("norad_id", noradId); return (TBuilder)this; } @@ -301,6 +410,30 @@ public TBuilder WithCustomer(string customer) return (TBuilder)this; } + /// + /// Filters launches by customer's nationality. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved customer name filter. + /// + /// The payload's customer nationality. + /// The launch builder. + public TBuilder WithNationality(string nationality) + { + AddFilter("nationality", nationality); + return (TBuilder)this; + } + + /// + /// Filters launches by payload's manufacturer. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved customer name filter. + /// + /// The payload's manufacturer name. + /// The launch builder. + public TBuilder WithManufacturer(string manufacturer) + { + AddFilter("manufacturer", manufacturer); + return (TBuilder)this; + } + /// /// Filters launches by payload type. Note that you have to call or /// to get result from the API. Every next call of this method will override previously saved payload type filter. @@ -326,51 +459,171 @@ public TBuilder WithOrbit(OrbitType orbit) } /// - /// Filters launches by launch success. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved launch success filter. + /// Filters launches by reference system. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. /// - /// The launch success. + /// The reference system. /// The launch builder. - public TBuilder WithLaunchSuccess(bool launchSuccess) + public TBuilder WithReferenceSystem(string referenceSystem) { - AddFilter("launch_success", launchSuccess); + AddFilter("reference_system", referenceSystem); return (TBuilder)this; } /// - /// Filters launches by reused flag. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved reused flag filter. + /// Filters launches by orbit regime. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. /// - /// The reused. + /// The orbit regime. /// The launch builder. - public TBuilder WithReused(bool reused) + public TBuilder WithRegime(string regime) { - AddFilter("reused", reused); + AddFilter("regime", regime); return (TBuilder)this; } /// - /// Filters launches by landing type. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved landing type filter. + /// Filters launches by orbit longitude. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. /// - /// The landing type (ASDS, Ocean, etc). + /// The orbit longitude. /// The launch builder. - public TBuilder WithLandingType(LandingType landingType) + public TBuilder WithLongitude(double longitude) { - AddFilter("landing_type", landingType.GetEnumMemberAttributeValue(landingType)); + AddFilter("longitude", longitude); return (TBuilder)this; } /// - /// Filters launches by landing vehicle. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved landing vehicle filter. + /// Filters launches by orbit semi major axis. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. /// - /// The landing vehicle (OCISLY, LZ1, etc). + /// The orbit semi major axis in kilometers. /// The launch builder. - public TBuilder WithLandingVehicle(LandingVehicleType landingVehicle) + public TBuilder WithSemiMajorAxisKilometers(double semiMajorAxis) { - AddFilter("landing_vehicle", landingVehicle.GetEnumMemberAttributeValue(landingVehicle)); + AddFilter("semi_major_axis_km", semiMajorAxis); + return (TBuilder)this; + } + + /// + /// Filters launches by orbit eccentricity. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. + /// + /// The orbit eccentricity. + /// The launch builder. + public TBuilder WithEccentricity(double eccentricity) + { + AddFilter("eccentricity", eccentricity); + return (TBuilder)this; + } + + /// + /// Filters launches by orbit periapsis. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. + /// + /// The orbit periapsis in kilometers. + /// The launch builder. + public TBuilder WithPeriapsisKilometers(double periapsis) + { + AddFilter("periapsis_km", periapsis); + return (TBuilder)this; + } + + /// + /// Filters launches by orbit apoapsis. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. + /// + /// The orbit apoapsis in kilometers. + /// The launch builder. + public TBuilder WithApoapsisKilometers(double apoapsis) + { + AddFilter("apoapsis_km", apoapsis); + return (TBuilder)this; + } + + /// + /// Filters launches by orbit inclination. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. + /// + /// The orbit inclination. + /// The launch builder. + public TBuilder WithInclinationDegrees(double inclination) + { + AddFilter("inclination_deg", inclination); + return (TBuilder)this; + } + + /// + /// Filters launches by orbit period time. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. + /// + /// The orbit period time in minutes. + /// The launch builder. + public TBuilder WithPeriodMinutes(double period) + { + AddFilter("period_min", period); + return (TBuilder)this; + } + + /// + /// Filters launches by orbit lifespan. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. + /// + /// The orbit lifespan in years. + /// The launch builder. + public TBuilder WithLifespanYears(double lifespan) + { + AddFilter("lifespan_years", lifespan); + return (TBuilder)this; + } + + /// + /// Filters launches by orbit epoch. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. + /// + /// The orbit epoch. + /// The launch builder. + public TBuilder WithEpoch(DateTime epoch) + { + AddFilter("epoch", epoch); + return (TBuilder)this; + } + + /// + /// Filters launches by orbit mean motion. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. + /// + /// The orbit mean motion. + /// The launch builder. + public TBuilder WithMeanMotion(double meanMotion) + { + AddFilter("mean_motion", meanMotion); + return (TBuilder)this; + } + + /// + /// Filters launches by orbit RAAN. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved orbit type filter. + /// + /// The orbit RAAN (right ascension of the ascending node). + /// The launch builder. + public TBuilder WithRaan(double raan) + { + AddFilter("raan", raan); + return (TBuilder)this; + } + + /// + /// Filters launches by launch success. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved launch success filter. + /// + /// The launch success. + /// The launch builder. + public TBuilder WithLaunchSuccess(bool launchSuccess) + { + AddFilter("launch_success", launchSuccess); return (TBuilder)this; } } -} +} \ No newline at end of file From 83fb301789330462046cb2560cdfec18d342433d Mon Sep 17 00:00:00 2001 From: Tearth Date: Mon, 29 Jun 2020 18:14:36 +0200 Subject: [PATCH 11/25] Fix Roadster endpoint --- Oddity/API/Builders/Roadster/RoadsterBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Oddity/API/Builders/Roadster/RoadsterBuilder.cs b/Oddity/API/Builders/Roadster/RoadsterBuilder.cs index 7c03cee..c2e24ec 100644 --- a/Oddity/API/Builders/Roadster/RoadsterBuilder.cs +++ b/Oddity/API/Builders/Roadster/RoadsterBuilder.cs @@ -9,7 +9,7 @@ namespace Oddity.API.Builders.Roadster /// public class RoadsterBuilder : BuilderBase { - private const string RoadsterInfoEndpoint = "info/roadster"; + private const string RoadsterInfoEndpoint = "roadster"; /// /// Initializes a new instance of the class. From e6f5d40858d9cd15bf7b08287da98fd900414f9d Mon Sep 17 00:00:00 2001 From: Tearth Date: Mon, 29 Jun 2020 18:18:27 +0200 Subject: [PATCH 12/25] Replace floats with doubles for better precision --- Oddity/API/Models/Common/MassInfo.cs | 4 +- Oddity/API/Models/Common/SizeInfo.cs | 4 +- Oddity/API/Models/Common/ThrustInfo.cs | 4 +- Oddity/API/Models/Common/VolumeInfo.cs | 4 +- .../Dragon/Heatshield/HeatshieldInfo.cs | 2 +- .../SecondStage/Orbit/OrbitParameters.cs | 24 +++++------ .../Launch/Rocket/SecondStage/PayloadInfo.cs | 4 +- .../API/Models/Launchpad/LaunchpadLocation.cs | 4 +- Oddity/API/Models/Roadster/RoadsterInfo.cs | 40 +++++++++---------- .../API/Models/Rocket/Engines/EnginesInfo.cs | 2 +- .../Models/Rocket/Stages/FirstStageInfo.cs | 2 +- 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Oddity/API/Models/Common/MassInfo.cs b/Oddity/API/Models/Common/MassInfo.cs index 11affb1..e69b9d9 100644 --- a/Oddity/API/Models/Common/MassInfo.cs +++ b/Oddity/API/Models/Common/MassInfo.cs @@ -5,9 +5,9 @@ namespace Oddity.API.Models.Common public class MassInfo { [JsonProperty("kg")] - public float? Kilograms { get; set; } + public double? Kilograms { get; set; } [JsonProperty("lb")] - public float? Pounds { get; set; } + public double? Pounds { get; set; } } } diff --git a/Oddity/API/Models/Common/SizeInfo.cs b/Oddity/API/Models/Common/SizeInfo.cs index 58ccdc5..b69fdaa 100644 --- a/Oddity/API/Models/Common/SizeInfo.cs +++ b/Oddity/API/Models/Common/SizeInfo.cs @@ -2,7 +2,7 @@ { public class SizeInfo { - public float? Meters { get; set; } - public float? Feet { get; set; } + public double? Meters { get; set; } + public double? Feet { get; set; } } } diff --git a/Oddity/API/Models/Common/ThrustInfo.cs b/Oddity/API/Models/Common/ThrustInfo.cs index 64656e8..a129a8f 100644 --- a/Oddity/API/Models/Common/ThrustInfo.cs +++ b/Oddity/API/Models/Common/ThrustInfo.cs @@ -5,9 +5,9 @@ namespace Oddity.API.Models.Common public class ThrustInfo { [JsonProperty("kn")] - public float? Kilonewtons { get; set; } + public double? Kilonewtons { get; set; } [JsonProperty("lbf")] - public float? PoundsForce { get; set; } + public double? PoundsForce { get; set; } } } diff --git a/Oddity/API/Models/Common/VolumeInfo.cs b/Oddity/API/Models/Common/VolumeInfo.cs index c03900f..4e2bfc2 100644 --- a/Oddity/API/Models/Common/VolumeInfo.cs +++ b/Oddity/API/Models/Common/VolumeInfo.cs @@ -5,9 +5,9 @@ namespace Oddity.API.Models.Common public class VolumeInfo { [JsonProperty("cubic_meters")] - public float? CubicMeters { get; set; } + public double? CubicMeters { get; set; } [JsonProperty("cubic_feet")] - public float? CubicFeet { get; set; } + public double? CubicFeet { get; set; } } } diff --git a/Oddity/API/Models/Dragon/Heatshield/HeatshieldInfo.cs b/Oddity/API/Models/Dragon/Heatshield/HeatshieldInfo.cs index c238850..220ec43 100644 --- a/Oddity/API/Models/Dragon/Heatshield/HeatshieldInfo.cs +++ b/Oddity/API/Models/Dragon/Heatshield/HeatshieldInfo.cs @@ -7,7 +7,7 @@ public class HeatshieldInfo public string Material { get; set; } [JsonProperty("size_meters")] - public float? SizeMeters { get; set; } + public double? SizeMeters { get; set; } [JsonProperty("temp_degrees")] public uint? MaxTemperatureDegrees { get; set; } diff --git a/Oddity/API/Models/Launch/Rocket/SecondStage/Orbit/OrbitParameters.cs b/Oddity/API/Models/Launch/Rocket/SecondStage/Orbit/OrbitParameters.cs index db8dab6..8fc3ab4 100644 --- a/Oddity/API/Models/Launch/Rocket/SecondStage/Orbit/OrbitParameters.cs +++ b/Oddity/API/Models/Launch/Rocket/SecondStage/Orbit/OrbitParameters.cs @@ -9,40 +9,40 @@ public class OrbitParameters public ReferenceSystemType? ReferenceSystem { get; set; } public OrbitRegime? Regime { get; set; } - public float? Longitude { get; set; } + public double? Longitude { get; set; } [JsonProperty("semi_major_axis_km")] - public float? SemiMajorAxisKilometers { get; set; } + public double? SemiMajorAxisKilometers { get; set; } - public float? Eccentricity { get; set; } + public double? Eccentricity { get; set; } [JsonProperty("periapsis_km")] - public float? PeriapsisKilometers { get; set; } + public double? PeriapsisKilometers { get; set; } [JsonProperty("apoapsis_km")] - public float? ApoapsisKilometers { get; set; } + public double? ApoapsisKilometers { get; set; } [JsonProperty("inclination_deg")] - public float? InclinationDegrees { get; set; } + public double? InclinationDegrees { get; set; } [JsonProperty("period_min")] - public float? PeriodMinutes { get; set; } + public double? PeriodMinutes { get; set; } [JsonProperty("lifespan_years")] - public float? LifespanYears { get; set; } + public double? LifespanYears { get; set; } public DateTime? Epoch { get; set; } [JsonProperty("mean_motion")] - public float? MeanMotion { get; set; } + public double? MeanMotion { get; set; } [JsonProperty("raan")] - public float? Raan { get; set; } + public double? Raan { get; set; } [JsonProperty("arg_of_pericenter")] - public float? ArgOfPericenter { get; set; } + public double? ArgOfPericenter { get; set; } [JsonProperty("mean_anomaly")] - public float? MeanAnomaly { get; set; } + public double? MeanAnomaly { get; set; } } } diff --git a/Oddity/API/Models/Launch/Rocket/SecondStage/PayloadInfo.cs b/Oddity/API/Models/Launch/Rocket/SecondStage/PayloadInfo.cs index 75491b8..c999523 100644 --- a/Oddity/API/Models/Launch/Rocket/SecondStage/PayloadInfo.cs +++ b/Oddity/API/Models/Launch/Rocket/SecondStage/PayloadInfo.cs @@ -21,10 +21,10 @@ public class PayloadInfo public string PayloadType { get; set; } [JsonProperty("payload_mass_kg")] - public float? PayloadMassKilograms { get; set; } + public double? PayloadMassKilograms { get; set; } [JsonProperty("payload_mass_lbs")] - public float? PayloadMassPounds { get; set; } + public double? PayloadMassPounds { get; set; } public OrbitType? Orbit { get; set; } diff --git a/Oddity/API/Models/Launchpad/LaunchpadLocation.cs b/Oddity/API/Models/Launchpad/LaunchpadLocation.cs index cf146d4..cd7f004 100644 --- a/Oddity/API/Models/Launchpad/LaunchpadLocation.cs +++ b/Oddity/API/Models/Launchpad/LaunchpadLocation.cs @@ -4,7 +4,7 @@ public class LaunchpadLocation { public string Name { get; set; } public string Region { get; set; } - public float? Latitude { get; set; } - public float? Longitude { get; set; } + public double? Latitude { get; set; } + public double? Longitude { get; set; } } } diff --git a/Oddity/API/Models/Roadster/RoadsterInfo.cs b/Oddity/API/Models/Roadster/RoadsterInfo.cs index 16200dc..f6ce1bc 100644 --- a/Oddity/API/Models/Roadster/RoadsterInfo.cs +++ b/Oddity/API/Models/Roadster/RoadsterInfo.cs @@ -8,62 +8,62 @@ public class RoadsterInfo public string Name { get; set; } [JsonProperty("launch_date_utc")] - public DateTime DateTimeUtc { get; set; } + public DateTime? DateTimeUtc { get; set; } [JsonProperty("launch_date_unix")] - public ulong DateTimeUnix { get; set; } + public ulong? DateTimeUnix { get; set; } [JsonProperty("launch_mass_kg")] - public uint LaunchMassKilograms { get; set; } + public uint? LaunchMassKilograms { get; set; } [JsonProperty("launch_mass_lbs")] - public uint LaunchMassPounds { get; set; } + public uint? LaunchMassPounds { get; set; } [JsonProperty("norad_id")] - public uint NoradId { get; set; } + public uint? NoradId { get; set; } [JsonProperty("epoch_jd")] - public float EpochJd { get; set; } + public double? EpochJd { get; set; } [JsonProperty("orbit_type")] public string OrbitType { get; set; } [JsonProperty("apoapsis_au")] - public float ApoapsisAu { get; set; } + public double? ApoapsisAu { get; set; } [JsonProperty("periapsis_au")] - public float PeriapsisAu { get; set; } + public double? PeriapsisAu { get; set; } [JsonProperty("semi_major_axis_au")] - public float SemiMajorAxisAu { get; set; } + public double? SemiMajorAxisAu { get; set; } - public float Eccentricity { get; set; } - public float Inclination { get; set; } - public float Longitude { get; set; } + public double? Eccentricity { get; set; } + public double? Inclination { get; set; } + public double? Longitude { get; set; } [JsonProperty("periapsis_arg")] - public float PeriapsisArg { get; set; } + public double? PeriapsisArg { get; set; } [JsonProperty("period_days")] - public float PeriodDays { get; set; } + public double? PeriodDays { get; set; } [JsonProperty("speed_kph")] - public float SpeedKph { get; set; } + public double? SpeedKph { get; set; } [JsonProperty("speed_mph")] - public float SpeedMph { get; set; } + public double? SpeedMph { get; set; } [JsonProperty("earth_distance_km")] - public float EarthDistanceKilometers { get; set; } + public double? EarthDistanceKilometers { get; set; } [JsonProperty("earth_distance_mi")] - public float EarthDistanceMiles { get; set; } + public double? EarthDistanceMiles { get; set; } [JsonProperty("mars_distance_km")] - public float MarsDistanceKilometers { get; set; } + public double? MarsDistanceKilometers { get; set; } [JsonProperty("mars_distance_mi")] - public float MarsDistanceMiles { get; set; } + public double? MarsDistanceMiles { get; set; } public string Wikipedia { get; set; } public string Details { get; set; } diff --git a/Oddity/API/Models/Rocket/Engines/EnginesInfo.cs b/Oddity/API/Models/Rocket/Engines/EnginesInfo.cs index 4f91473..6182ebf 100644 --- a/Oddity/API/Models/Rocket/Engines/EnginesInfo.cs +++ b/Oddity/API/Models/Rocket/Engines/EnginesInfo.cs @@ -26,6 +26,6 @@ public class EnginesInfo public ThrustInfo ThrustVacuum { get; set; } [JsonProperty("thrust_to_weight")] - public float? ThrustToWeight { get; set; } + public double? ThrustToWeight { get; set; } } } diff --git a/Oddity/API/Models/Rocket/Stages/FirstStageInfo.cs b/Oddity/API/Models/Rocket/Stages/FirstStageInfo.cs index 780cfcb..7e32493 100644 --- a/Oddity/API/Models/Rocket/Stages/FirstStageInfo.cs +++ b/Oddity/API/Models/Rocket/Stages/FirstStageInfo.cs @@ -9,7 +9,7 @@ public class FirstStageInfo public int Engines { get; set; } [JsonProperty("fuel_amount_tons")] - public float? FuelAmountTons { get; set; } + public double? FuelAmountTons { get; set; } [JsonProperty("burn_time_sec")] public int? BurnTimeSeconds { get; set; } From cc04afcf7cc0db745ae8d28394e9721e839745f1 Mon Sep 17 00:00:00 2001 From: Tearth Date: Mon, 29 Jun 2020 18:22:49 +0200 Subject: [PATCH 13/25] Add missing nullable types --- Oddity/API/Models/DetailedCapsule/CapsuleMissionInfo.cs | 2 +- Oddity/API/Models/DetailedCore/CoreMissionInfo.cs | 2 +- Oddity/API/Models/Dragon/DragonInfo.cs | 4 ++-- Oddity/API/Models/History/HistoryEvent.cs | 2 +- Oddity/API/Models/Launchpad/LaunchpadInfo.cs | 2 +- Oddity/API/Models/Rocket/Engines/EnginesInfo.cs | 2 +- Oddity/API/Models/Rocket/PayloadWeights/PayloadWeightInfo.cs | 2 +- Oddity/API/Models/Rocket/RocketInfo.cs | 2 +- Oddity/API/Models/Rocket/Stages/FirstStageInfo.cs | 4 ++-- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Oddity/API/Models/DetailedCapsule/CapsuleMissionInfo.cs b/Oddity/API/Models/DetailedCapsule/CapsuleMissionInfo.cs index 159075d..b74563c 100644 --- a/Oddity/API/Models/DetailedCapsule/CapsuleMissionInfo.cs +++ b/Oddity/API/Models/DetailedCapsule/CapsuleMissionInfo.cs @@ -3,6 +3,6 @@ public class CapsuleMissionInfo { public string Name { get; set; } - public int Flight { get; set; } + public int? Flight { get; set; } } } diff --git a/Oddity/API/Models/DetailedCore/CoreMissionInfo.cs b/Oddity/API/Models/DetailedCore/CoreMissionInfo.cs index a5e47c8..a914f87 100644 --- a/Oddity/API/Models/DetailedCore/CoreMissionInfo.cs +++ b/Oddity/API/Models/DetailedCore/CoreMissionInfo.cs @@ -3,6 +3,6 @@ public class CoreMissionInfo { public string Name { get; set; } - public int Flight { get; set; } + public int? Flight { get; set; } } } diff --git a/Oddity/API/Models/Dragon/DragonInfo.cs b/Oddity/API/Models/Dragon/DragonInfo.cs index daba27a..c1d0aa5 100644 --- a/Oddity/API/Models/Dragon/DragonInfo.cs +++ b/Oddity/API/Models/Dragon/DragonInfo.cs @@ -25,10 +25,10 @@ public class DragonInfo public uint? OrbitDurationYears { get; set; } [JsonProperty("dry_mass_kg")] - public float DryMassKilograms { get; set; } + public float? DryMassKilograms { get; set; } [JsonProperty("dry_mass_lb")] - public float DryMassPounds { get; set; } + public float? DryMassPounds { get; set; } [JsonProperty("first_flight")] public DateTime FirstFlight { get; set; } diff --git a/Oddity/API/Models/History/HistoryEvent.cs b/Oddity/API/Models/History/HistoryEvent.cs index 72c0313..a89c217 100644 --- a/Oddity/API/Models/History/HistoryEvent.cs +++ b/Oddity/API/Models/History/HistoryEvent.cs @@ -5,7 +5,7 @@ namespace Oddity.API.Models.History { public class HistoryEvent { - public int Id { get; set; } + public int? Id { get; set; } public string Title { get; set; } [JsonProperty("event_date_utc")] diff --git a/Oddity/API/Models/Launchpad/LaunchpadInfo.cs b/Oddity/API/Models/Launchpad/LaunchpadInfo.cs index 6bc9879..1d2d8ec 100644 --- a/Oddity/API/Models/Launchpad/LaunchpadInfo.cs +++ b/Oddity/API/Models/Launchpad/LaunchpadInfo.cs @@ -10,7 +10,7 @@ public class LaunchpadInfo [JsonProperty("full_name")] public string FullName { get; set; } - public LaunchpadStatus Status { get; set; } + public LaunchpadStatus? Status { get; set; } public LaunchpadLocation Location { get; set; } [JsonProperty("vehicles_launched")] diff --git a/Oddity/API/Models/Rocket/Engines/EnginesInfo.cs b/Oddity/API/Models/Rocket/Engines/EnginesInfo.cs index 6182ebf..b51e37c 100644 --- a/Oddity/API/Models/Rocket/Engines/EnginesInfo.cs +++ b/Oddity/API/Models/Rocket/Engines/EnginesInfo.cs @@ -6,7 +6,7 @@ namespace Oddity.API.Models.Rocket.Engines public class EnginesInfo { public uint? Number { get; set; } - public EngineType Type { get; set; } + public EngineType? Type { get; set; } public string Version { get; set; } public string Layout { get; set; } diff --git a/Oddity/API/Models/Rocket/PayloadWeights/PayloadWeightInfo.cs b/Oddity/API/Models/Rocket/PayloadWeights/PayloadWeightInfo.cs index 821648a..acb7b5b 100644 --- a/Oddity/API/Models/Rocket/PayloadWeights/PayloadWeightInfo.cs +++ b/Oddity/API/Models/Rocket/PayloadWeights/PayloadWeightInfo.cs @@ -5,7 +5,7 @@ namespace Oddity.API.Models.Rocket.PayloadWeights public class PayloadWeightInfo { [JsonProperty("id")] - public PayloadType Type { get; set; } + public PayloadType? Type { get; set; } public string Name { get; set; } diff --git a/Oddity/API/Models/Rocket/RocketInfo.cs b/Oddity/API/Models/Rocket/RocketInfo.cs index e79cd33..a2f8152 100644 --- a/Oddity/API/Models/Rocket/RocketInfo.cs +++ b/Oddity/API/Models/Rocket/RocketInfo.cs @@ -11,7 +11,7 @@ namespace Oddity.API.Models.Rocket { public class RocketInfo { - public RocketId Id { get; set; } + public RocketId? Id { get; set; } public string Name { get; set; } public bool? Active { get; set; } diff --git a/Oddity/API/Models/Rocket/Stages/FirstStageInfo.cs b/Oddity/API/Models/Rocket/Stages/FirstStageInfo.cs index 7e32493..d8f0876 100644 --- a/Oddity/API/Models/Rocket/Stages/FirstStageInfo.cs +++ b/Oddity/API/Models/Rocket/Stages/FirstStageInfo.cs @@ -5,8 +5,8 @@ namespace Oddity.API.Models.Rocket.Stages { public class FirstStageInfo { - public bool Reusable { get; set; } - public int Engines { get; set; } + public bool? Reusable { get; set; } + public int? Engines { get; set; } [JsonProperty("fuel_amount_tons")] public double? FuelAmountTons { get; set; } From 03afafee121b180a343691e9f45ef5ac6a497370 Mon Sep 17 00:00:00 2001 From: Tearth Date: Mon, 29 Jun 2020 18:33:33 +0200 Subject: [PATCH 14/25] Move detailed capsules to capsules endpoint --- .../AllCapsulesBuilder.cs} | 58 +++++++++++-------- .../CapsuleBuilder.cs} | 18 +++--- Oddity/API/Builders/History/EventBuilder.cs | 1 - .../API/{DetailedCapsules.cs => Capsules.cs} | 20 +++---- .../CapsuleInfo.cs} | 9 ++- .../CapsuleMissionInfo.cs | 2 +- .../CapsuleStatus.cs} | 4 +- Oddity/OddityCore.cs | 6 +- 8 files changed, 66 insertions(+), 52 deletions(-) rename Oddity/API/Builders/{DetailedCapsules/AllDetailedCapsulesBuilder.cs => Capsules/AllCapsulesBuilder.cs} (66%) rename Oddity/API/Builders/{DetailedCapsules/DetailedCapsuleBuilder.cs => Capsules/CapsuleBuilder.cs} (63%) rename Oddity/API/{DetailedCapsules.cs => Capsules.cs} (67%) rename Oddity/API/Models/{DetailedCapsule/DetailedCapsuleInfo.cs => Capsule/CapsuleInfo.cs} (77%) rename Oddity/API/Models/{DetailedCapsule => Capsule}/CapsuleMissionInfo.cs (74%) rename Oddity/API/Models/{DetailedCapsule/DetailedCapsuleStatus.cs => Capsule/CapsuleStatus.cs} (77%) diff --git a/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs b/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs similarity index 66% rename from Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs rename to Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs index 2ff487b..c8ffe42 100644 --- a/Oddity/API/Builders/DetailedCapsules/AllDetailedCapsulesBuilder.cs +++ b/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs @@ -2,25 +2,25 @@ using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; -using Oddity.API.Models.DetailedCapsule; +using Oddity.API.Models.Capsule; using Oddity.API.Models.Dragon; using Oddity.Helpers; -namespace Oddity.API.Builders.DetailedCapsules +namespace Oddity.API.Builders.Capsules { /// - /// Represents a set of methods to filter all detailed capsules information and download them from API. + /// Represents a set of methods to filter all capsules information and download them from API. /// - public class AllDetailedCapsulesBuilder : BuilderBase> + public class AllCapsulesBuilder : BuilderBase> { - private const string CapsuleInfoEndpoint = "parts/caps"; + private const string CapsuleInfoEndpoint = "capsules"; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The HTTP client. /// The builder delegates container. - public AllDetailedCapsulesBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + public AllCapsulesBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) { } @@ -30,8 +30,8 @@ public AllDetailedCapsulesBuilder(HttpClient httpClient, BuilderDelegatesContain /// to get result from the API. Every next call of this method will override previously saved capsule serial filter. /// /// The capsule serial (C101, C102, etc). - /// The detailed capsules builder. - public AllDetailedCapsulesBuilder WithCapsuleSerial(string capsuleSerial) + /// The capsules builder. + public AllCapsulesBuilder WithCapsuleSerial(string capsuleSerial) { AddFilter("capsule_serial", capsuleSerial); return this; @@ -42,8 +42,8 @@ public AllDetailedCapsulesBuilder WithCapsuleSerial(string capsuleSerial) /// to get result from the API. Every next call of this method will override previously saved capsule id filter. /// /// The capsule id (Dragon 1, Dragon 2 etc). - /// The detailed capsules builder. - public AllDetailedCapsulesBuilder WithCapsuleId(DragonId capsuleId) + /// The capsules builder. + public AllCapsulesBuilder WithCapsuleId(DragonId capsuleId) { AddFilter("capsule_id", capsuleId.GetEnumMemberAttributeValue(capsuleId)); return this; @@ -54,8 +54,8 @@ public AllDetailedCapsulesBuilder WithCapsuleId(DragonId capsuleId) /// to get result from the API. Every next call of this method will override previously saved capsule status filter. /// /// The capsule status (active, retired etc). - /// The detailed capsules builder. - public AllDetailedCapsulesBuilder WithStatus(DetailedCapsuleStatus status) + /// The capsules builder. + public AllCapsulesBuilder WithStatus(CapsuleStatus status) { AddFilter("status", status.GetEnumMemberAttributeValue(status)); return this; @@ -66,8 +66,8 @@ public AllDetailedCapsulesBuilder WithStatus(DetailedCapsuleStatus status) /// to get result from the API. Every next call of this method will override previously saved original launch filter. /// /// The capsule original launch. - /// The detailed capsules builder. - public AllDetailedCapsulesBuilder WithOriginalLaunch(DateTime originalLaunch) + /// The capsules builder. + public AllCapsulesBuilder WithOriginalLaunch(DateTime originalLaunch) { AddFilter("original_launch", originalLaunch, DateFormatType.Long); return this; @@ -78,8 +78,8 @@ public AllDetailedCapsulesBuilder WithOriginalLaunch(DateTime originalLaunch) /// to get result from the API. Every next call of this method will override previously saved missions filter. /// /// The capsule mission (SpaceX CRS-8, ZUMA, etc). - /// The detailed capsules builder. - public AllDetailedCapsulesBuilder WithMission(string mission) + /// The capsules builder. + public AllCapsulesBuilder WithMission(string mission) { AddFilter("mission", mission); return this; @@ -89,9 +89,9 @@ public AllDetailedCapsulesBuilder WithMission(string mission) /// Filters launches by landings count. Note that you have to call or /// to get result from the API. Every next call of this method will override previously saved landings count filter. /// - /// The capsule mission (SpaceX CRS-8, ZUMA, etc). - /// The detailed capsules builder. - public AllDetailedCapsulesBuilder WithLandingsCount(int landingsCount) + /// Landing count. + /// The capsules builder. + public AllCapsulesBuilder WithLandingsCount(int landingsCount) { AddFilter("landings", landingsCount); return this; @@ -102,15 +102,27 @@ public AllDetailedCapsulesBuilder WithLandingsCount(int landingsCount) /// to get result from the API. Every next call of this method will override previously saved capsule type filter. /// /// The capsule type (Dragon 1.1, Dragon 2.0, etc). - /// The detailed capsules builder. - public AllDetailedCapsulesBuilder WithCapsuleType(string capsuleType) + /// The capsules builder. + public AllCapsulesBuilder WithCapsuleType(string capsuleType) { AddFilter("type", capsuleType); return this; } + /// + /// Filters launches by reuse count. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved landings count filter. + /// + /// Reuse count. + /// The capsules builder. + public AllCapsulesBuilder WithReuseCount(int reuseCount) + { + AddFilter("reuse_count", reuseCount); + return this; + } + /// - protected override async Task> ExecuteBuilder() + protected override async Task> ExecuteBuilder() { var link = BuildLink(CapsuleInfoEndpoint); return await SendRequestToApi(link).ConfigureAwait(false); diff --git a/Oddity/API/Builders/DetailedCapsules/DetailedCapsuleBuilder.cs b/Oddity/API/Builders/Capsules/CapsuleBuilder.cs similarity index 63% rename from Oddity/API/Builders/DetailedCapsules/DetailedCapsuleBuilder.cs rename to Oddity/API/Builders/Capsules/CapsuleBuilder.cs index ad3cbf6..929fb21 100644 --- a/Oddity/API/Builders/DetailedCapsules/DetailedCapsuleBuilder.cs +++ b/Oddity/API/Builders/Capsules/CapsuleBuilder.cs @@ -1,23 +1,23 @@ using System.Net.Http; using System.Threading.Tasks; -using Oddity.API.Models.DetailedCapsule; +using Oddity.API.Models.Capsule; -namespace Oddity.API.Builders.DetailedCapsules +namespace Oddity.API.Builders.Capsules { /// - /// Represents a set of methods to filter detailed capsule information and download them from API. + /// Represents a set of methods to filter capsule information and download them from API. /// - public class DetailedCapsuleBuilder : BuilderBase + public class CapsuleBuilder : BuilderBase { private string _capsuleSerial; - private const string CapsuleInfoEndpoint = "parts/caps"; + private const string CapsuleInfoEndpoint = "capsules"; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The HTTP client. /// The builder delegates container. - public DetailedCapsuleBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + public CapsuleBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) { } @@ -28,14 +28,14 @@ public DetailedCapsuleBuilder(HttpClient httpClient, BuilderDelegatesContainer b /// /// The capsule serial (C101, C102, etc). /// The capsule information. - public DetailedCapsuleBuilder WithSerial(string capsuleSerial) + public CapsuleBuilder WithSerial(string capsuleSerial) { _capsuleSerial = capsuleSerial; return this; } /// - protected override async Task ExecuteBuilder() + protected override async Task ExecuteBuilder() { var link = BuildLink(CapsuleInfoEndpoint); if (_capsuleSerial != null) diff --git a/Oddity/API/Builders/History/EventBuilder.cs b/Oddity/API/Builders/History/EventBuilder.cs index 09788cc..963fd67 100644 --- a/Oddity/API/Builders/History/EventBuilder.cs +++ b/Oddity/API/Builders/History/EventBuilder.cs @@ -1,6 +1,5 @@ using System.Net.Http; using System.Threading.Tasks; -using Oddity.API.Models.DetailedCapsule; using Oddity.API.Models.History; namespace Oddity.API.Builders.History diff --git a/Oddity/API/DetailedCapsules.cs b/Oddity/API/Capsules.cs similarity index 67% rename from Oddity/API/DetailedCapsules.cs rename to Oddity/API/Capsules.cs index db18c56..9f6d044 100644 --- a/Oddity/API/DetailedCapsules.cs +++ b/Oddity/API/Capsules.cs @@ -1,23 +1,23 @@ using System.Net.Http; using Oddity.API.Builders; -using Oddity.API.Builders.DetailedCapsules; +using Oddity.API.Builders.Capsules; namespace Oddity.API { /// - /// Represents a set of methods to get detailed capsules information. + /// Represents a set of methods to get capsules information. /// - public class DetailedCapsules + public class Capsules { private readonly HttpClient _httpClient; private readonly BuilderDelegatesContainer _builderDelegatesContainer; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The HTTP client. /// The builder delegates container. - public DetailedCapsules(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) + public Capsules(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) { _httpClient = httpClient; _builderDelegatesContainer = builderDelegatesContainer; @@ -30,9 +30,9 @@ public DetailedCapsules(HttpClient httpClient, BuilderDelegatesContainer builder /// /// The capsule serial. /// The capsule builder. - public DetailedCapsuleBuilder GetAbout(string capsuleSerial) + public CapsuleBuilder GetAbout(string capsuleSerial) { - return new DetailedCapsuleBuilder(_httpClient, _builderDelegatesContainer).WithSerial(capsuleSerial); + return new CapsuleBuilder(_httpClient, _builderDelegatesContainer).WithSerial(capsuleSerial); } /// @@ -40,10 +40,10 @@ public DetailedCapsuleBuilder GetAbout(string capsuleSerial) /// all necessary filters you should call or to /// get the data from SpaceX API. /// - /// The all detailed capsules builder. - public AllDetailedCapsulesBuilder GetAll() + /// The all capsules builder. + public AllCapsulesBuilder GetAll() { - return new AllDetailedCapsulesBuilder(_httpClient, _builderDelegatesContainer); + return new AllCapsulesBuilder(_httpClient, _builderDelegatesContainer); } } } diff --git a/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs b/Oddity/API/Models/Capsule/CapsuleInfo.cs similarity index 77% rename from Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs rename to Oddity/API/Models/Capsule/CapsuleInfo.cs index ba976f4..65549f0 100644 --- a/Oddity/API/Models/DetailedCapsule/DetailedCapsuleInfo.cs +++ b/Oddity/API/Models/Capsule/CapsuleInfo.cs @@ -3,9 +3,9 @@ using Newtonsoft.Json; using Oddity.API.Models.Dragon; -namespace Oddity.API.Models.DetailedCapsule +namespace Oddity.API.Models.Capsule { - public class DetailedCapsuleInfo + public class CapsuleInfo { [JsonProperty("capsule_serial")] public string CapsuleSerial { get; set; } @@ -13,7 +13,7 @@ public class DetailedCapsuleInfo [JsonProperty("capsule_id")] public DragonId? CapsuleId { get; set; } - public DetailedCapsuleStatus? Status { get; set; } + public CapsuleStatus? Status { get; set; } [JsonProperty("original_launch")] public DateTime? OriginalLaunch { get; set; } @@ -25,5 +25,8 @@ public class DetailedCapsuleInfo public uint? Landings { get; set; } public string Type { get; set; } public string Details { get; set; } + + [JsonProperty("reuse_count")] + public int? ReuseCount { get; set; } } } diff --git a/Oddity/API/Models/DetailedCapsule/CapsuleMissionInfo.cs b/Oddity/API/Models/Capsule/CapsuleMissionInfo.cs similarity index 74% rename from Oddity/API/Models/DetailedCapsule/CapsuleMissionInfo.cs rename to Oddity/API/Models/Capsule/CapsuleMissionInfo.cs index b74563c..32c8e43 100644 --- a/Oddity/API/Models/DetailedCapsule/CapsuleMissionInfo.cs +++ b/Oddity/API/Models/Capsule/CapsuleMissionInfo.cs @@ -1,4 +1,4 @@ -namespace Oddity.API.Models.DetailedCapsule +namespace Oddity.API.Models.Capsule { public class CapsuleMissionInfo { diff --git a/Oddity/API/Models/DetailedCapsule/DetailedCapsuleStatus.cs b/Oddity/API/Models/Capsule/CapsuleStatus.cs similarity index 77% rename from Oddity/API/Models/DetailedCapsule/DetailedCapsuleStatus.cs rename to Oddity/API/Models/Capsule/CapsuleStatus.cs index cdd025e..172fd8c 100644 --- a/Oddity/API/Models/DetailedCapsule/DetailedCapsuleStatus.cs +++ b/Oddity/API/Models/Capsule/CapsuleStatus.cs @@ -1,8 +1,8 @@ using System.Runtime.Serialization; -namespace Oddity.API.Models.DetailedCapsule +namespace Oddity.API.Models.Capsule { - public enum DetailedCapsuleStatus + public enum CapsuleStatus { [EnumMember(Value = "active")] Active, diff --git a/Oddity/OddityCore.cs b/Oddity/OddityCore.cs index 0c4c49f..d9065df 100644 --- a/Oddity/OddityCore.cs +++ b/Oddity/OddityCore.cs @@ -38,9 +38,9 @@ public class OddityCore : IDisposable public Dragons Dragons { get; } /// - /// Gets the detailed capsules information. + /// Gets the capsules information. /// - public DetailedCapsules DetailedCapsules { get; } + public Capsules Capsules { get; } /// /// Gets the detailed core information. @@ -102,7 +102,7 @@ public OddityCore() History = new History(_httpClient, builderDelegatesContainer); Rockets = new Rockets(_httpClient, builderDelegatesContainer); Dragons = new Dragons(_httpClient, builderDelegatesContainer); - DetailedCapsules = new DetailedCapsules(_httpClient, builderDelegatesContainer); + Capsules = new Capsules(_httpClient, builderDelegatesContainer); DetailedCores = new DetailedCores(_httpClient, builderDelegatesContainer); Launchpads = new Launchpads(_httpClient, builderDelegatesContainer); Launches = new Launches(_httpClient, builderDelegatesContainer); From 27a14f12ba466e8d7b702b933e7ce7dfd91f6604 Mon Sep 17 00:00:00 2001 From: Tearth Date: Mon, 29 Jun 2020 19:25:59 +0200 Subject: [PATCH 15/25] Add support for past and upcoming capsules --- .../Builders/Capsules/AllCapsulesBuilder.cs | 98 +------------- .../Builders/Capsules/CapsuleBuilderBase.cs | 122 ++++++++++++++++++ .../Builders/Capsules/PastCapsulesBuilder.cs | 35 +++++ .../Capsules/UpcomingCapsulesBuilder.cs | 35 +++++ Oddity/API/Capsules.cs | 22 ++++ 5 files changed, 215 insertions(+), 97 deletions(-) create mode 100644 Oddity/API/Builders/Capsules/CapsuleBuilderBase.cs create mode 100644 Oddity/API/Builders/Capsules/PastCapsulesBuilder.cs create mode 100644 Oddity/API/Builders/Capsules/UpcomingCapsulesBuilder.cs diff --git a/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs b/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs index c8ffe42..c327094 100644 --- a/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs +++ b/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs @@ -11,7 +11,7 @@ namespace Oddity.API.Builders.Capsules /// /// Represents a set of methods to filter all capsules information and download them from API. /// - public class AllCapsulesBuilder : BuilderBase> + public class AllCapsulesBuilder : CapsuleBuilderBase> { private const string CapsuleInfoEndpoint = "capsules"; @@ -25,102 +25,6 @@ public AllCapsulesBuilder(HttpClient httpClient, BuilderDelegatesContainer build } - /// - /// Filters launches by capsule serial. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved capsule serial filter. - /// - /// The capsule serial (C101, C102, etc). - /// The capsules builder. - public AllCapsulesBuilder WithCapsuleSerial(string capsuleSerial) - { - AddFilter("capsule_serial", capsuleSerial); - return this; - } - - /// - /// Filters launches by capsule id. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved capsule id filter. - /// - /// The capsule id (Dragon 1, Dragon 2 etc). - /// The capsules builder. - public AllCapsulesBuilder WithCapsuleId(DragonId capsuleId) - { - AddFilter("capsule_id", capsuleId.GetEnumMemberAttributeValue(capsuleId)); - return this; - } - - /// - /// Filters launches by capsule status. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved capsule status filter. - /// - /// The capsule status (active, retired etc). - /// The capsules builder. - public AllCapsulesBuilder WithStatus(CapsuleStatus status) - { - AddFilter("status", status.GetEnumMemberAttributeValue(status)); - return this; - } - - /// - /// Filters launches by original launch. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved original launch filter. - /// - /// The capsule original launch. - /// The capsules builder. - public AllCapsulesBuilder WithOriginalLaunch(DateTime originalLaunch) - { - AddFilter("original_launch", originalLaunch, DateFormatType.Long); - return this; - } - - /// - /// Filters launches by missions. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved missions filter. - /// - /// The capsule mission (SpaceX CRS-8, ZUMA, etc). - /// The capsules builder. - public AllCapsulesBuilder WithMission(string mission) - { - AddFilter("mission", mission); - return this; - } - - /// - /// Filters launches by landings count. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved landings count filter. - /// - /// Landing count. - /// The capsules builder. - public AllCapsulesBuilder WithLandingsCount(int landingsCount) - { - AddFilter("landings", landingsCount); - return this; - } - - /// - /// Filters launches by capsule type. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved capsule type filter. - /// - /// The capsule type (Dragon 1.1, Dragon 2.0, etc). - /// The capsules builder. - public AllCapsulesBuilder WithCapsuleType(string capsuleType) - { - AddFilter("type", capsuleType); - return this; - } - - /// - /// Filters launches by reuse count. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved landings count filter. - /// - /// Reuse count. - /// The capsules builder. - public AllCapsulesBuilder WithReuseCount(int reuseCount) - { - AddFilter("reuse_count", reuseCount); - return this; - } - /// protected override async Task> ExecuteBuilder() { diff --git a/Oddity/API/Builders/Capsules/CapsuleBuilderBase.cs b/Oddity/API/Builders/Capsules/CapsuleBuilderBase.cs new file mode 100644 index 0000000..8664e29 --- /dev/null +++ b/Oddity/API/Builders/Capsules/CapsuleBuilderBase.cs @@ -0,0 +1,122 @@ +using System; +using System.Net.Http; +using Oddity.API.Models.Capsule; +using Oddity.API.Models.Dragon; +using Oddity.Helpers; + +namespace Oddity.API.Builders.Capsules +{ + /// + /// Represents an abstract class for all capsule builders. Contains methods to the detailed filters that aren't present in other builders. + /// + /// The launch builder type. + /// The returned object type. + public abstract class CapsuleBuilderBase : BuilderBase where TBuilder : CapsuleBuilderBase where TReturn : class + { + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + /// The builder delegates container. + protected CapsuleBuilderBase(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + { + + } + + /// + /// Filters launches by capsule serial. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved capsule serial filter. + /// + /// The capsule serial (C101, C102, etc). + /// The capsules builder. + public TBuilder WithCapsuleSerial(string capsuleSerial) + { + AddFilter("capsule_serial", capsuleSerial); + return (TBuilder)this; + } + + /// + /// Filters launches by capsule id. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved capsule id filter. + /// + /// The capsule id (Dragon 1, Dragon 2 etc). + /// The capsules builder. + public TBuilder WithCapsuleId(DragonId capsuleId) + { + AddFilter("capsule_id", capsuleId.GetEnumMemberAttributeValue(capsuleId)); + return (TBuilder)this; + } + + /// + /// Filters launches by capsule status. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved capsule status filter. + /// + /// The capsule status (active, retired etc). + /// The capsules builder. + public TBuilder WithStatus(CapsuleStatus status) + { + AddFilter("status", status.GetEnumMemberAttributeValue(status)); + return (TBuilder)this; + } + + /// + /// Filters launches by original launch. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved original launch filter. + /// + /// The capsule original launch. + /// The capsules builder. + public TBuilder WithOriginalLaunch(DateTime originalLaunch) + { + AddFilter("original_launch", originalLaunch, DateFormatType.Long); + return (TBuilder)this; + } + + /// + /// Filters launches by missions. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved missions filter. + /// + /// The capsule mission (SpaceX CRS-8, ZUMA, etc). + /// The capsules builder. + public TBuilder WithMission(string mission) + { + AddFilter("mission", mission); + return (TBuilder)this; + } + + /// + /// Filters launches by landings count. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved landings count filter. + /// + /// Landing count. + /// The capsules builder. + public TBuilder WithLandingsCount(int landingsCount) + { + AddFilter("landings", landingsCount); + return (TBuilder)this; + } + + /// + /// Filters launches by capsule type. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved capsule type filter. + /// + /// The capsule type (Dragon 1.1, Dragon 2.0, etc). + /// The capsules builder. + public TBuilder WithCapsuleType(string capsuleType) + { + AddFilter("type", capsuleType); + return (TBuilder)this; + } + + /// + /// Filters launches by reuse count. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved landings count filter. + /// + /// Reuse count. + /// The capsules builder. + public TBuilder WithReuseCount(int reuseCount) + { + AddFilter("reuse_count", reuseCount); + return (TBuilder)this; + } + } +} \ No newline at end of file diff --git a/Oddity/API/Builders/Capsules/PastCapsulesBuilder.cs b/Oddity/API/Builders/Capsules/PastCapsulesBuilder.cs new file mode 100644 index 0000000..3320fd3 --- /dev/null +++ b/Oddity/API/Builders/Capsules/PastCapsulesBuilder.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Oddity.API.Models.Capsule; +using Oddity.API.Models.Dragon; +using Oddity.Helpers; + +namespace Oddity.API.Builders.Capsules +{ + /// + /// Represents a set of methods to filter all upcoming capsules information and download them from API. + /// + public class PastCapsulesBuilder : CapsuleBuilderBase> + { + private const string CapsuleInfoEndpoint = "capsules/past"; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + /// The builder delegates container. + public PastCapsulesBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + { + + } + + /// + protected override async Task> ExecuteBuilder() + { + var link = BuildLink(CapsuleInfoEndpoint); + return await SendRequestToApi(link).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/Oddity/API/Builders/Capsules/UpcomingCapsulesBuilder.cs b/Oddity/API/Builders/Capsules/UpcomingCapsulesBuilder.cs new file mode 100644 index 0000000..c548d35 --- /dev/null +++ b/Oddity/API/Builders/Capsules/UpcomingCapsulesBuilder.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Oddity.API.Models.Capsule; +using Oddity.API.Models.Dragon; +using Oddity.Helpers; + +namespace Oddity.API.Builders.Capsules +{ + /// + /// Represents a set of methods to filter all upcoming capsules information and download them from API. + /// + public class UpcomingCapsulesBuilder : CapsuleBuilderBase> + { + private const string CapsuleInfoEndpoint = "capsules/upcoming"; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + /// The builder delegates container. + public UpcomingCapsulesBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + { + + } + + /// + protected override async Task> ExecuteBuilder() + { + var link = BuildLink(CapsuleInfoEndpoint); + return await SendRequestToApi(link).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/Oddity/API/Capsules.cs b/Oddity/API/Capsules.cs index 9f6d044..5ec0cb8 100644 --- a/Oddity/API/Capsules.cs +++ b/Oddity/API/Capsules.cs @@ -45,5 +45,27 @@ public AllCapsulesBuilder GetAll() { return new AllCapsulesBuilder(_httpClient, _builderDelegatesContainer); } + + /// + /// Gets detailed information about upcoming capsules. This method returns only builder which doesn't retrieve data from API itself, so after apply + /// all necessary filters you should call or to + /// get the data from SpaceX API. + /// + /// The all capsules builder. + public UpcomingCapsulesBuilder GetUpcoming() + { + return new UpcomingCapsulesBuilder(_httpClient, _builderDelegatesContainer); + } + + /// + /// Gets detailed information about past capsules. This method returns only builder which doesn't retrieve data from API itself, so after apply + /// all necessary filters you should call or to + /// get the data from SpaceX API. + /// + /// The all capsules builder. + public PastCapsulesBuilder GetPast() + { + return new PastCapsulesBuilder(_httpClient, _builderDelegatesContainer); + } } } From e0ddc9b8dbb00a34728aaa5e082ed657cb3fe262 Mon Sep 17 00:00:00 2001 From: Tearth Date: Tue, 30 Jun 2020 15:44:26 +0200 Subject: [PATCH 16/25] Rename detailed cores to cores --- .../Builders/Capsules/AllCapsulesBuilder.cs | 2 +- .../AllCoresBuilder.cs} | 46 +++++++++---------- .../CoreBuilder.cs} | 16 +++---- Oddity/API/{DetailedCores.cs => Cores.cs} | 20 ++++---- .../DetailedCoreInfo.cs => Core/CoreInfo.cs} | 4 +- .../{DetailedCore => Core}/CoreMissionInfo.cs | 0 .../CoreStatus.cs} | 2 +- Oddity/OddityCore.cs | 6 +-- 8 files changed, 48 insertions(+), 48 deletions(-) rename Oddity/API/Builders/{DetailedCores/AllDetailedCoresBuilder.cs => Cores/AllCoresBuilder.cs} (73%) rename Oddity/API/Builders/{DetailedCores/DetailedCoreBuilder.cs => Cores/CoreBuilder.cs} (65%) rename Oddity/API/{DetailedCores.cs => Cores.cs} (68%) rename Oddity/API/Models/{DetailedCore/DetailedCoreInfo.cs => Core/CoreInfo.cs} (92%) rename Oddity/API/Models/{DetailedCore => Core}/CoreMissionInfo.cs (100%) rename Oddity/API/Models/{DetailedCore/DetailedCoreStatus.cs => Core/CoreStatus.cs} (90%) diff --git a/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs b/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs index c327094..80dd575 100644 --- a/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs +++ b/Oddity/API/Builders/Capsules/AllCapsulesBuilder.cs @@ -22,7 +22,7 @@ public class AllCapsulesBuilder : CapsuleBuilderBaseThe builder delegates container. public AllCapsulesBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) { - + } /// diff --git a/Oddity/API/Builders/DetailedCores/AllDetailedCoresBuilder.cs b/Oddity/API/Builders/Cores/AllCoresBuilder.cs similarity index 73% rename from Oddity/API/Builders/DetailedCores/AllDetailedCoresBuilder.cs rename to Oddity/API/Builders/Cores/AllCoresBuilder.cs index fca0356..4b7e048 100644 --- a/Oddity/API/Builders/DetailedCores/AllDetailedCoresBuilder.cs +++ b/Oddity/API/Builders/Cores/AllCoresBuilder.cs @@ -5,21 +5,21 @@ using Oddity.API.Models.DetailedCore; using Oddity.Helpers; -namespace Oddity.API.Builders.DetailedCores +namespace Oddity.API.Builders.Cores { /// - /// Represents a set of methods to filter detailed core information and download them from API. + /// Represents a set of methods to filter core information and download them from API. /// - public class AllDetailedCoresBuilder : BuilderBase> + public class AllCoresBuilder : BuilderBase> { - private const string CapsuleInfoEndpoint = "parts/cores"; + private const string CapsuleInfoEndpoint = "cores"; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The HTTP client. /// The builder delegates container. - public AllDetailedCoresBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + public AllCoresBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) { } @@ -29,8 +29,8 @@ public AllDetailedCoresBuilder(HttpClient httpClient, BuilderDelegatesContainer /// to get result from the API. Every next call of this method will override previously saved core serial filter. /// /// The core serial (B0005, B1012, etc). - /// The all detailed cores builder. - public AllDetailedCoresBuilder WithCoreSerial(string coreSerial) + /// The all cores builder. + public AllCoresBuilder WithCoreSerial(string coreSerial) { AddFilter("core_serial", coreSerial); return this; @@ -41,8 +41,8 @@ public AllDetailedCoresBuilder WithCoreSerial(string coreSerial) /// to get result from the API. Every next call of this method will override previously saved core block number filter. /// /// The block number. - /// The all detailed cores builder. - public AllDetailedCoresBuilder WithBlock(int block) + /// The all cores builder. + public AllCoresBuilder WithBlock(int block) { AddFilter("block", block); return this; @@ -53,8 +53,8 @@ public AllDetailedCoresBuilder WithBlock(int block) /// to get result from the API. Every next call of this method will override previously saved core status filter. /// /// The core status (active, destroyed, etc). - /// The all detailed cores builder. - public AllDetailedCoresBuilder WithStatus(DetailedCoreStatus status) + /// The all cores builder. + public AllCoresBuilder WithStatus(CoreStatus status) { AddFilter("status", status.GetEnumMemberAttributeValue(status)); return this; @@ -65,8 +65,8 @@ public AllDetailedCoresBuilder WithStatus(DetailedCoreStatus status) /// to get result from the API. Every next call of this method will override previously saved original launch filter. /// /// The core original launch. - /// vThe all detailed cores builder. - public AllDetailedCoresBuilder WithOriginalLaunch(DateTime originalLaunch) + /// vThe all cores builder. + public AllCoresBuilder WithOriginalLaunch(DateTime originalLaunch) { AddFilter("original_launch", originalLaunch, DateFormatType.Long); return this; @@ -77,8 +77,8 @@ public AllDetailedCoresBuilder WithOriginalLaunch(DateTime originalLaunch) /// to get result from the API. Every next call of this method will override previously saved missions filter. /// /// The core mission. - /// The all detailed cores builder. - public AllDetailedCoresBuilder WithMission(string mission) + /// The all cores builder. + public AllCoresBuilder WithMission(string mission) { AddFilter("mission", mission); return this; @@ -89,8 +89,8 @@ public AllDetailedCoresBuilder WithMission(string mission) /// to get result from the API. Every next call of this method will override previously saved RTLS landing filter. /// /// The core RTLS (return to launch site) landings count. - /// The all detailed cores builder. - public AllDetailedCoresBuilder WithRtlsLanding(int rtlsLandings) + /// The all cores builder. + public AllCoresBuilder WithRtlsLanding(int rtlsLandings) { AddFilter("rtls_landings", rtlsLandings); return this; @@ -101,8 +101,8 @@ public AllDetailedCoresBuilder WithRtlsLanding(int rtlsLandings) /// to get result from the API. Every next call of this method will override previously saved ASDS landing filter. /// /// The core ASDS (autonomous spaceport drone ship) landings count. - /// The all detailed cores builder. - public AllDetailedCoresBuilder WithAsdsLanding(int asdsLandings) + /// The all cores builder. + public AllCoresBuilder WithAsdsLanding(int asdsLandings) { AddFilter("asds_landings", asdsLandings); return this; @@ -113,15 +113,15 @@ public AllDetailedCoresBuilder WithAsdsLanding(int asdsLandings) /// to get result from the API. Every next call of this method will override previously saved water landing filter. /// /// The core water landing. - /// The all detailed cores builder. - public AllDetailedCoresBuilder WithWaterLanding(bool waterLanding) + /// The all cores builder. + public AllCoresBuilder WithWaterLanding(bool waterLanding) { AddFilter("water_landing", waterLanding); return this; } /// - protected override async Task> ExecuteBuilder() + protected override async Task> ExecuteBuilder() { var link = BuildLink(CapsuleInfoEndpoint); return await SendRequestToApi(link).ConfigureAwait(false); diff --git a/Oddity/API/Builders/DetailedCores/DetailedCoreBuilder.cs b/Oddity/API/Builders/Cores/CoreBuilder.cs similarity index 65% rename from Oddity/API/Builders/DetailedCores/DetailedCoreBuilder.cs rename to Oddity/API/Builders/Cores/CoreBuilder.cs index 9056677..9a7d8cf 100644 --- a/Oddity/API/Builders/DetailedCores/DetailedCoreBuilder.cs +++ b/Oddity/API/Builders/Cores/CoreBuilder.cs @@ -2,22 +2,22 @@ using System.Threading.Tasks; using Oddity.API.Models.DetailedCore; -namespace Oddity.API.Builders.DetailedCores +namespace Oddity.API.Builders.Cores { /// - /// Represents a set of methods to filter detailed core information and download them from API. + /// Represents a set of methods to filter core information and download them from API. /// - public class DetailedCoreBuilder : BuilderBase + public class CoreBuilder : BuilderBase { private string _coreSerial; - private const string CapsuleInfoEndpoint = "parts/cores"; + private const string CapsuleInfoEndpoint = "cores"; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The HTTP client. /// The builder delegates container. - public DetailedCoreBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + public CoreBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) { } @@ -28,14 +28,14 @@ public DetailedCoreBuilder(HttpClient httpClient, BuilderDelegatesContainer buil /// /// The capsule serial (C101, C113, etc). /// The capsule information. - public DetailedCoreBuilder WithSerial(string coreSerial) + public CoreBuilder WithSerial(string coreSerial) { _coreSerial = coreSerial; return this; } /// - protected override async Task ExecuteBuilder() + protected override async Task ExecuteBuilder() { var link = BuildLink(CapsuleInfoEndpoint); if (_coreSerial != null) diff --git a/Oddity/API/DetailedCores.cs b/Oddity/API/Cores.cs similarity index 68% rename from Oddity/API/DetailedCores.cs rename to Oddity/API/Cores.cs index 569a438..e46a570 100644 --- a/Oddity/API/DetailedCores.cs +++ b/Oddity/API/Cores.cs @@ -1,23 +1,23 @@ using System.Net.Http; using Oddity.API.Builders; -using Oddity.API.Builders.DetailedCores; +using Oddity.API.Builders.Cores; namespace Oddity.API { /// - /// Represents a set of methods to get detailed cores information. + /// Represents a set of methods to get cores information. /// - public class DetailedCores + public class Cores { private readonly HttpClient _httpClient; private readonly BuilderDelegatesContainer _builderDelegatesContainer; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The HTTP client. /// The builder delegates container. - public DetailedCores(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) + public Cores(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) { _httpClient = httpClient; _builderDelegatesContainer = builderDelegatesContainer; @@ -30,9 +30,9 @@ public DetailedCores(HttpClient httpClient, BuilderDelegatesContainer builderDel /// /// The core serial. /// The capsule builder. - public DetailedCoreBuilder GetAbout(string coreSerial) + public CoreBuilder GetAbout(string coreSerial) { - return new DetailedCoreBuilder(_httpClient, _builderDelegatesContainer).WithSerial(coreSerial); + return new CoreBuilder(_httpClient, _builderDelegatesContainer).WithSerial(coreSerial); } /// @@ -40,10 +40,10 @@ public DetailedCoreBuilder GetAbout(string coreSerial) /// all necessary filters you should call or to /// get the data from SpaceX API. /// - /// The all detailed core builder. - public AllDetailedCoresBuilder GetAll() + /// The all core builder. + public AllCoresBuilder GetAll() { - return new AllDetailedCoresBuilder(_httpClient, _builderDelegatesContainer); + return new AllCoresBuilder(_httpClient, _builderDelegatesContainer); } } } diff --git a/Oddity/API/Models/DetailedCore/DetailedCoreInfo.cs b/Oddity/API/Models/Core/CoreInfo.cs similarity index 92% rename from Oddity/API/Models/DetailedCore/DetailedCoreInfo.cs rename to Oddity/API/Models/Core/CoreInfo.cs index cd70336..5efd2ac 100644 --- a/Oddity/API/Models/DetailedCore/DetailedCoreInfo.cs +++ b/Oddity/API/Models/Core/CoreInfo.cs @@ -4,13 +4,13 @@ namespace Oddity.API.Models.DetailedCore { - public class DetailedCoreInfo + public class CoreInfo { [JsonProperty("core_serial")] public string CoreSerial { get; set; } public uint? Block { get; set; } - public DetailedCoreStatus? Status { get; set; } + public CoreStatus? Status { get; set; } [JsonProperty("original_launch")] public DateTime? OriginalLaunch { get; set; } diff --git a/Oddity/API/Models/DetailedCore/CoreMissionInfo.cs b/Oddity/API/Models/Core/CoreMissionInfo.cs similarity index 100% rename from Oddity/API/Models/DetailedCore/CoreMissionInfo.cs rename to Oddity/API/Models/Core/CoreMissionInfo.cs diff --git a/Oddity/API/Models/DetailedCore/DetailedCoreStatus.cs b/Oddity/API/Models/Core/CoreStatus.cs similarity index 90% rename from Oddity/API/Models/DetailedCore/DetailedCoreStatus.cs rename to Oddity/API/Models/Core/CoreStatus.cs index 77c4081..9f1b16d 100644 --- a/Oddity/API/Models/DetailedCore/DetailedCoreStatus.cs +++ b/Oddity/API/Models/Core/CoreStatus.cs @@ -2,7 +2,7 @@ namespace Oddity.API.Models.DetailedCore { - public enum DetailedCoreStatus + public enum CoreStatus { [EnumMember(Value = "active")] Active, diff --git a/Oddity/OddityCore.cs b/Oddity/OddityCore.cs index d9065df..983a5d0 100644 --- a/Oddity/OddityCore.cs +++ b/Oddity/OddityCore.cs @@ -43,9 +43,9 @@ public class OddityCore : IDisposable public Capsules Capsules { get; } /// - /// Gets the detailed core information. + /// Gets the core information. /// - public DetailedCores DetailedCores { get; } + public Cores Cores { get; } /// /// Gets the launchpads information. @@ -103,7 +103,7 @@ public OddityCore() Rockets = new Rockets(_httpClient, builderDelegatesContainer); Dragons = new Dragons(_httpClient, builderDelegatesContainer); Capsules = new Capsules(_httpClient, builderDelegatesContainer); - DetailedCores = new DetailedCores(_httpClient, builderDelegatesContainer); + Cores = new Cores(_httpClient, builderDelegatesContainer); Launchpads = new Launchpads(_httpClient, builderDelegatesContainer); Launches = new Launches(_httpClient, builderDelegatesContainer); Roadster = new Roadster(_httpClient, builderDelegatesContainer); From 232a9c822afa35a1b99ee5899cbf13ca7f02f34c Mon Sep 17 00:00:00 2001 From: Tearth Date: Tue, 30 Jun 2020 15:49:49 +0200 Subject: [PATCH 17/25] Add new endpoints for cores --- Oddity/API/Builders/Cores/AllCoresBuilder.cs | 100 +-------------- Oddity/API/Builders/Cores/CoreBuilderBase.cs | 121 ++++++++++++++++++ Oddity/API/Builders/Cores/PastCoresBuilder.cs | 34 +++++ .../Builders/Cores/UpcomingCoresBuilder.cs | 34 +++++ Oddity/API/Cores.cs | 22 ++++ 5 files changed, 213 insertions(+), 98 deletions(-) create mode 100644 Oddity/API/Builders/Cores/CoreBuilderBase.cs create mode 100644 Oddity/API/Builders/Cores/PastCoresBuilder.cs create mode 100644 Oddity/API/Builders/Cores/UpcomingCoresBuilder.cs diff --git a/Oddity/API/Builders/Cores/AllCoresBuilder.cs b/Oddity/API/Builders/Cores/AllCoresBuilder.cs index 4b7e048..e0f213e 100644 --- a/Oddity/API/Builders/Cores/AllCoresBuilder.cs +++ b/Oddity/API/Builders/Cores/AllCoresBuilder.cs @@ -8,9 +8,9 @@ namespace Oddity.API.Builders.Cores { /// - /// Represents a set of methods to filter core information and download them from API. + /// Represents a set of methods to filter all cores information and download them from API. /// - public class AllCoresBuilder : BuilderBase> + public class AllCoresBuilder : CoreBuilderBase> { private const string CapsuleInfoEndpoint = "cores"; @@ -24,102 +24,6 @@ public AllCoresBuilder(HttpClient httpClient, BuilderDelegatesContainer builderD } - /// - /// Filters launches by core serial. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved core serial filter. - /// - /// The core serial (B0005, B1012, etc). - /// The all cores builder. - public AllCoresBuilder WithCoreSerial(string coreSerial) - { - AddFilter("core_serial", coreSerial); - return this; - } - - /// - /// Filters launches by core block number. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved core block number filter. - /// - /// The block number. - /// The all cores builder. - public AllCoresBuilder WithBlock(int block) - { - AddFilter("block", block); - return this; - } - - /// - /// Filters launches by core status. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved core status filter. - /// - /// The core status (active, destroyed, etc). - /// The all cores builder. - public AllCoresBuilder WithStatus(CoreStatus status) - { - AddFilter("status", status.GetEnumMemberAttributeValue(status)); - return this; - } - - /// - /// Filters launches by original launch. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved original launch filter. - /// - /// The core original launch. - /// vThe all cores builder. - public AllCoresBuilder WithOriginalLaunch(DateTime originalLaunch) - { - AddFilter("original_launch", originalLaunch, DateFormatType.Long); - return this; - } - - /// - /// Filters launches by missions. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved missions filter. - /// - /// The core mission. - /// The all cores builder. - public AllCoresBuilder WithMission(string mission) - { - AddFilter("mission", mission); - return this; - } - - /// - /// Filters launches by RTLS landing. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved RTLS landing filter. - /// - /// The core RTLS (return to launch site) landings count. - /// The all cores builder. - public AllCoresBuilder WithRtlsLanding(int rtlsLandings) - { - AddFilter("rtls_landings", rtlsLandings); - return this; - } - - /// - /// Filters launches by ASDS landing. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved ASDS landing filter. - /// - /// The core ASDS (autonomous spaceport drone ship) landings count. - /// The all cores builder. - public AllCoresBuilder WithAsdsLanding(int asdsLandings) - { - AddFilter("asds_landings", asdsLandings); - return this; - } - - /// - /// Filters launches by water landing. Note that you have to call or - /// to get result from the API. Every next call of this method will override previously saved water landing filter. - /// - /// The core water landing. - /// The all cores builder. - public AllCoresBuilder WithWaterLanding(bool waterLanding) - { - AddFilter("water_landing", waterLanding); - return this; - } - /// protected override async Task> ExecuteBuilder() { diff --git a/Oddity/API/Builders/Cores/CoreBuilderBase.cs b/Oddity/API/Builders/Cores/CoreBuilderBase.cs new file mode 100644 index 0000000..7d725bb --- /dev/null +++ b/Oddity/API/Builders/Cores/CoreBuilderBase.cs @@ -0,0 +1,121 @@ +using System; +using System.Net.Http; +using Oddity.API.Models.DetailedCore; +using Oddity.Helpers; + +namespace Oddity.API.Builders.Cores +{ + /// + /// Represents an abstract class for all core builders. Contains methods to the detailed filters that aren't present in other builders. + /// + /// The launch builder type. + /// The returned object type. + public abstract class CoreBuilderBase : BuilderBase where TBuilder : CoreBuilderBase where TReturn : class + { + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + /// The builder delegates container. + protected CoreBuilderBase(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + { + + } + + /// + /// Filters launches by core serial. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved core serial filter. + /// + /// The core serial (B0005, B1012, etc). + /// The all cores builder. + public TBuilder WithCoreSerial(string coreSerial) + { + AddFilter("core_serial", coreSerial); + return (TBuilder)this; + } + + /// + /// Filters launches by core block number. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved core block number filter. + /// + /// The block number. + /// The all cores builder. + public TBuilder WithBlock(int block) + { + AddFilter("block", block); + return (TBuilder)this; + } + + /// + /// Filters launches by core status. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved core status filter. + /// + /// The core status (active, destroyed, etc). + /// The all cores builder. + public TBuilder WithStatus(CoreStatus status) + { + AddFilter("status", status.GetEnumMemberAttributeValue(status)); + return (TBuilder)this; + } + + /// + /// Filters launches by original launch. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved original launch filter. + /// + /// The core original launch. + /// vThe all cores builder. + public TBuilder WithOriginalLaunch(DateTime originalLaunch) + { + AddFilter("original_launch", originalLaunch, DateFormatType.Long); + return (TBuilder)this; + } + + /// + /// Filters launches by missions. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved missions filter. + /// + /// The core mission. + /// The all cores builder. + public TBuilder WithMission(string mission) + { + AddFilter("mission", mission); + return (TBuilder)this; + } + + /// + /// Filters launches by RTLS landing. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved RTLS landing filter. + /// + /// The core RTLS (return to launch site) landings count. + /// The all cores builder. + public TBuilder WithRtlsLanding(int rtlsLandings) + { + AddFilter("rtls_landings", rtlsLandings); + return (TBuilder)this; + } + + /// + /// Filters launches by ASDS landing. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved ASDS landing filter. + /// + /// The core ASDS (autonomous spaceport drone ship) landings count. + /// The all cores builder. + public TBuilder WithAsdsLanding(int asdsLandings) + { + AddFilter("asds_landings", asdsLandings); + return (TBuilder)this; + } + + /// + /// Filters launches by water landing. Note that you have to call or + /// to get result from the API. Every next call of this method will override previously saved water landing filter. + /// + /// The core water landing. + /// The all cores builder. + public TBuilder WithWaterLanding(bool waterLanding) + { + AddFilter("water_landing", waterLanding); + return (TBuilder)this; + } + } +} \ No newline at end of file diff --git a/Oddity/API/Builders/Cores/PastCoresBuilder.cs b/Oddity/API/Builders/Cores/PastCoresBuilder.cs new file mode 100644 index 0000000..b280edc --- /dev/null +++ b/Oddity/API/Builders/Cores/PastCoresBuilder.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Oddity.API.Models.DetailedCore; +using Oddity.Helpers; + +namespace Oddity.API.Builders.Cores +{ + /// + /// Represents a set of methods to filter past cores information and download them from API. + /// + public class PastCoresBuilder : CoreBuilderBase> + { + private const string CapsuleInfoEndpoint = "cores/past"; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + /// The builder delegates container. + public PastCoresBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + { + + } + + /// + protected override async Task> ExecuteBuilder() + { + var link = BuildLink(CapsuleInfoEndpoint); + return await SendRequestToApi(link).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/Oddity/API/Builders/Cores/UpcomingCoresBuilder.cs b/Oddity/API/Builders/Cores/UpcomingCoresBuilder.cs new file mode 100644 index 0000000..1ee7d09 --- /dev/null +++ b/Oddity/API/Builders/Cores/UpcomingCoresBuilder.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Oddity.API.Models.DetailedCore; +using Oddity.Helpers; + +namespace Oddity.API.Builders.Cores +{ + /// + /// Represents a set of methods to filter upcoming cores information and download them from API. + /// + public class UpcomingCoresBuilder : CoreBuilderBase> + { + private const string CapsuleInfoEndpoint = "cores/upcoming"; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + /// The builder delegates container. + public UpcomingCoresBuilder(HttpClient httpClient, BuilderDelegatesContainer builderDelegatesContainer) : base(httpClient, builderDelegatesContainer) + { + + } + + /// + protected override async Task> ExecuteBuilder() + { + var link = BuildLink(CapsuleInfoEndpoint); + return await SendRequestToApi(link).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/Oddity/API/Cores.cs b/Oddity/API/Cores.cs index e46a570..eb53d0d 100644 --- a/Oddity/API/Cores.cs +++ b/Oddity/API/Cores.cs @@ -45,5 +45,27 @@ public AllCoresBuilder GetAll() { return new AllCoresBuilder(_httpClient, _builderDelegatesContainer); } + + /// + /// Gets detailed information about upcoming cores. This method returns only builder which doesn't retrieve data from API itself, so after apply + /// all necessary filters you should call or to + /// get the data from SpaceX API. + /// + /// The all capsules builder. + public UpcomingCoresBuilder GetUpcoming() + { + return new UpcomingCoresBuilder(_httpClient, _builderDelegatesContainer); + } + + /// + /// Gets detailed information about past cores. This method returns only builder which doesn't retrieve data from API itself, so after apply + /// all necessary filters you should call or to + /// get the data from SpaceX API. + /// + /// The all capsules builder. + public PastCoresBuilder GetPast() + { + return new PastCoresBuilder(_httpClient, _builderDelegatesContainer); + } } } From fbc7f3c6881f0349afdbdd563c3f7ee6973ac6eb Mon Sep 17 00:00:00 2001 From: Tearth Date: Fri, 3 Jul 2020 17:56:25 +0200 Subject: [PATCH 18/25] Add missing fields to launchpad info --- Oddity/API/Models/Launchpad/LaunchpadInfo.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Oddity/API/Models/Launchpad/LaunchpadInfo.cs b/Oddity/API/Models/Launchpad/LaunchpadInfo.cs index 1d2d8ec..8aaaf29 100644 --- a/Oddity/API/Models/Launchpad/LaunchpadInfo.cs +++ b/Oddity/API/Models/Launchpad/LaunchpadInfo.cs @@ -5,10 +5,10 @@ namespace Oddity.API.Models.Launchpad { public class LaunchpadInfo { - public LaunchpadId? Id { get; set; } + public int? Id { get; set; } - [JsonProperty("full_name")] - public string FullName { get; set; } + [JsonProperty("site_id")] + public LaunchpadId? SiteId { get; set; } public LaunchpadStatus? Status { get; set; } public LaunchpadLocation Location { get; set; } @@ -16,6 +16,17 @@ public class LaunchpadInfo [JsonProperty("vehicles_launched")] public List VehiclesLaunched { get; set; } + [JsonProperty("attempted_launches")] + public int? AttemptedLaunches { get; set; } + + [JsonProperty("successful_launches")] + public int? SuccessfulLaunches { get; set; } + + public string Wikipedia { get; set; } public string Details { get; set; } + + [JsonProperty("site_name_long")] + public string FullName { get; set; } + } } From 8d0b66bb4686a997958c29ac9f4dc77f284cf52f Mon Sep 17 00:00:00 2001 From: Tearth Date: Fri, 3 Jul 2020 17:56:47 +0200 Subject: [PATCH 19/25] Update overview program --- Examples/OverviewApp/Program.cs | 40 ++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/Examples/OverviewApp/Program.cs b/Examples/OverviewApp/Program.cs index 87e5f5b..258c385 100644 --- a/Examples/OverviewApp/Program.cs +++ b/Examples/OverviewApp/Program.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json.Serialization; using Oddity; using Oddity.API.Builders; +using Oddity.API.Models.Dragon; using Oddity.API.Models.Launch.Rocket.SecondStage.Orbit; using Oddity.API.Models.Rocket; @@ -19,18 +20,24 @@ static async Task Main(string[] args) oddity.OnRequestSend += Oddity_OnRequestSend; oddity.OnResponseReceive += OddityOnResponseReceive; + // Get API information + var apiInfo = await oddity.Api.GetInfo().ExecuteAsync(); + // Get company information var company = await oddity.Company.GetInfo().ExecuteAsync(); // Get all history - var history = await oddity.Company.GetHistory().ExecuteAsync(); + var history = await oddity.History.GetAll().ExecuteAsync(); // Get history from the last two years and ordered descending - var historyWithFilter = await oddity.Company.GetHistory() + var historyWithFilter = await oddity.History.GetAll() .WithRange(DateTime.Now.AddYears(-2), DateTime.Now) .Descending() .ExecuteAsync(); + // Get single history event + var historyEvent = await oddity.History.GetEvent(5).ExecuteAsync(); + // Get data about Falcon Heavy var falconHeavy = await oddity.Rockets.GetAbout(RocketId.FalconHeavy).ExecuteAsync(); @@ -40,6 +47,9 @@ static async Task Main(string[] args) // Get information about the next launch var nextLaunch = await oddity.Launches.GetNext().ExecuteAsync(); + // Get information about the specified launch + var specifiedLaunch = await oddity.Launches.Get(65).ExecuteAsync(); + // Get data about all launches of Falcon 9 which has been launched to ISS. Next, sort it ascending var launchWithFilters = await oddity.Launches.GetAll() .WithRocketName("Falcon 9") @@ -47,16 +57,34 @@ static async Task Main(string[] args) .Ascending() .ExecuteAsync(); - // Get all capsule types - var capsuleTypes = await oddity.Capsules.GetAll().ExecuteAsync(); + // Get all Dragon types + var dragonTypes = await oddity.Dragons.GetAll().ExecuteAsync(); + + // Get all Dragon types + var crewDragon = await oddity.Dragons.GetAbout(DragonId.Dragon2).ExecuteAsync(); + + // Get all capsules + var allCapsules = await oddity.Capsules.GetAll().ExecuteAsync(); + + // Past capsules + var pastCapsules = await oddity.Capsules.GetPast().ExecuteAsync(); + + // Upcoming capsules + var upcomingCapsules = await oddity.Capsules.GetUpcoming().ExecuteAsync(); // Get capsule which has been launched 2015-04-14 at 20:10 - var capsuleWithFilters = await oddity.DetailedCapsules.GetAll() + var capsuleWithFilters = await oddity.Capsules.GetAll() .WithOriginalLaunch(new DateTime(2015, 4, 14, 20, 10, 0)) .ExecuteAsync(); // Get all cores - var allCores = await oddity.DetailedCores.GetAll().ExecuteAsync(); + var allCores = await oddity.Cores.GetAll().ExecuteAsync(); + + // Get past cores + var pastCores = await oddity.Cores.GetPast().ExecuteAsync(); + + // Get upcoming cores + var upcomingCores = await oddity.Cores.GetUpcoming().ExecuteAsync(); // Get Roadster info var roadster = await oddity.Roadster.Get().ExecuteAsync(); From 025952c944fb4a09fa4c7f20bcf3490c3f9893cf Mon Sep 17 00:00:00 2001 From: Tearth Date: Fri, 3 Jul 2020 18:10:03 +0200 Subject: [PATCH 20/25] Add info about v1.0.13 release --- CHANGELOG.md | 8 ++++++++ Oddity/Oddity.csproj | 14 +++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb15a71..032ed49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# Version 1.0.13 (03-07-2020) +* Change API version to v3 +* Add new endpoints support for history, capsules and cores +* Added missing fields to the models +* Fix models inconsistency + +WARNING: this is the last release for v2/v3 API version. The next one will be completely rewritten to support v4 within a month or two - it won't be compatible backward. More info: https://github.com/r-spacex/SpaceX-API/issues/380 + # Version 1.0.12 (26-02-2020) * Added methods to retrieve information about API * Cleaned up code diff --git a/Oddity/Oddity.csproj b/Oddity/Oddity.csproj index d392d7a..67f15a8 100644 --- a/Oddity/Oddity.csproj +++ b/Oddity/Oddity.csproj @@ -7,16 +7,20 @@ https://github.com/Tearth/Oddity https://github.com/Tearth/Oddity oddity spacex api wrapper dotnet .net csharp dotnetstandard .netstandard standard core framework - * Added methods to retrieve information about API -* Cleaned up code + * Change API version to v3 +* Add new endpoints support for history, capsules and cores +* Added missing fields to the models +* Fix models inconsistency + +WARNING: this is the last release for v2/v3 API version. The next one will be completely rewritten to support v4 within a month or two - it won't be compatible backward. More info: https://github.com/r-spacex/SpaceX-API/issues/380 SpaceX API wrapper for .NET based on the https://github.com/r-spacex/SpaceX-API project. Tearth 2020 true false - 1.0.12.0 - 1.0.12.0 - 1.0.12 + 1.0.13.0 + 1.0.13.0 + 1.0.13 https://raw.githubusercontent.com/Tearth/Oddity/develop/icon.png git From 4bf67db1756dbb6b03a64d7e8adb65881256d0bf Mon Sep 17 00:00:00 2001 From: Tearth Date: Sat, 4 Jul 2020 13:47:48 +0200 Subject: [PATCH 21/25] Add info about library future in README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index be52628..0f4ba34 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ https://docs.spacexdata.com/ +**WARNING: v1.0.13 is the last release for v2/v3 API version. The next one will be completely rewritten to support v4 within a month or two - it won't be compatible backward. More info: https://github.com/r-spacex/SpaceX-API/issues/380** + **Available data overview:** * company data, history with most important events * detailed information about rockets (Falcon 1, Falcon 9, Falcon Heavy, BFR) and capsules (Dragon 1, Dragon 2, crew Dragon) From 6124b37d158789bf17a73b6f1c8c7af2c15b6741 Mon Sep 17 00:00:00 2001 From: Tearth Date: Sat, 4 Jul 2020 13:48:50 +0200 Subject: [PATCH 22/25] Fix typos --- CHANGELOG.md | 6 +++--- Oddity/Oddity.csproj | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 032ed49..2b776c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Version 1.0.13 (03-07-2020) -* Change API version to v3 -* Add new endpoints support for history, capsules and cores +* Changed API version to v3 +* Added new endpoints support for history, capsules and cores * Added missing fields to the models -* Fix models inconsistency +* Fixed models inconsistency WARNING: this is the last release for v2/v3 API version. The next one will be completely rewritten to support v4 within a month or two - it won't be compatible backward. More info: https://github.com/r-spacex/SpaceX-API/issues/380 diff --git a/Oddity/Oddity.csproj b/Oddity/Oddity.csproj index 67f15a8..5ed63fc 100644 --- a/Oddity/Oddity.csproj +++ b/Oddity/Oddity.csproj @@ -7,10 +7,10 @@ https://github.com/Tearth/Oddity https://github.com/Tearth/Oddity oddity spacex api wrapper dotnet .net csharp dotnetstandard .netstandard standard core framework - * Change API version to v3 -* Add new endpoints support for history, capsules and cores + * Changed API version to v3 +* Added new endpoints support for history, capsules and cores * Added missing fields to the models -* Fix models inconsistency +* Fixed models inconsistency WARNING: this is the last release for v2/v3 API version. The next one will be completely rewritten to support v4 within a month or two - it won't be compatible backward. More info: https://github.com/r-spacex/SpaceX-API/issues/380 SpaceX API wrapper for .NET based on the https://github.com/r-spacex/SpaceX-API project. From 78a2c74041be9c8072213e2d6633a9c3fe90812d Mon Sep 17 00:00:00 2001 From: Tearth Date: Sat, 4 Jul 2020 13:54:56 +0200 Subject: [PATCH 23/25] Update .NET version in Travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8353840..0f9aa29 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: csharp dist: trusty mono: none -dotnet: 2.0.0 +dotnet: 2.2.105 before_install: - sudo apt-get update && sudo apt install -y doxygen script: From 7fb54e769c823365f6c6857424a7a44733794bee Mon Sep 17 00:00:00 2001 From: Tearth Date: Sat, 4 Jul 2020 13:58:08 +0200 Subject: [PATCH 24/25] Change distro in Travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0f9aa29..bfd2076 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: csharp -dist: trusty +dist: xenial mono: none dotnet: 2.2.105 before_install: From 9cd21c17b2f2acd15d590ce3c0e60250ef241651 Mon Sep 17 00:00:00 2001 From: Tearth Date: Sat, 4 Jul 2020 14:55:38 +0200 Subject: [PATCH 25/25] Fix typos in changelog --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b776c3..1b95c9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Version 1.0.13 (03-07-2020) -* Changed API version to v3 -* Added new endpoints support for history, capsules and cores -* Added missing fields to the models -* Fixed models inconsistency + * Changed API version to v3 + * Added new endpoints support for history, capsules and cores + * Added missing fields to the models + * Fixed models inconsistency WARNING: this is the last release for v2/v3 API version. The next one will be completely rewritten to support v4 within a month or two - it won't be compatible backward. More info: https://github.com/r-spacex/SpaceX-API/issues/380