Skip to content

Commit

Permalink
Optimization profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Koval authored and Dmitry Koval committed Jan 15, 2024
1 parent bf9283c commit c114540
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 0 deletions.
5 changes: 5 additions & 0 deletions route4me-csharp-sdk/Route4MeSDKLibrary/Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ public static class R4MEInfrastructureSettingsV5
public const string Workflows = MainHost + "/workflows";
#endregion

#region Optimization Profiles
public const string OptimizationProfiles = MainHost + "/optimization-profiles";
public const string OptimizationProfilesList = OptimizationProfiles + "/list";
#endregion

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,12 @@ public sealed class RouteParameters
/// </summary>
[DataMember(Name = "group_max_routes", EmitDefaultValue = false)]
public List<object[]> GroupMaxRoutes { get; set; }

/// <summary>
/// Route start date local
/// </summary>
[DataMember(Name = "route_start_date_local", EmitDefaultValue = false)]
public string RouteStartDateLocal { get; set; }
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Runtime.Serialization;

namespace Route4MeSDKLibrary.DataTypes.V5.OptimizationProfiles
{
/// <summary>
/// Optimization profile
/// </summary>
[DataContract]
public class OptimizationProfile
{
/// <summary>
/// Optimization profile ID
/// </summary>
[DataMember(Name = "optimization_profile_id", EmitDefaultValue = false)]
public string Id { get; set; }

/// <summary>
/// Profile name
/// </summary>
[DataMember(Name = "profile_name", EmitDefaultValue = false)]
public string Name { get; set; }

/// <summary>
/// Is default
/// </summary>
[DataMember(Name = "is_default", EmitDefaultValue = false)]
public bool IsDefault { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Runtime.Serialization;

namespace Route4MeSDKLibrary.DataTypes.V5.OptimizationProfiles
{
/// <summary>
/// Optimization profiles response
/// </summary>
[DataContract]
public class OptimizationProfilesResponse
{
/// <summary>
/// Optimization profiles
/// </summary>
[DataMember(Name = "items", EmitDefaultValue = false)]
public OptimizationProfile[] Items { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,12 @@ public class RouteParameters
/// </summary>
[DataMember(Name = "group_max_routes", EmitDefaultValue = false)]
public List<object[]> GroupMaxRoutes { get; set; }

/// <summary>
/// Route start date local
/// </summary>
[DataMember(Name = "route_start_date_local", EmitDefaultValue = false)]
public string RouteStartDateLocal { get; set; }
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Route4MeSDK.DataTypes.V5;
using Route4MeSDK;
using System.Threading.Tasks;
using System;
using Route4MeSDK.QueryTypes;
using Route4MeSDKLibrary.DataTypes.V5.OptimizationProfiles;

namespace Route4MeSDKLibrary.Managers
{
public class OptimizationProfileManagerV5 : Route4MeManagerBase
{
public OptimizationProfileManagerV5(string apiKey) : base(apiKey)
{
}

/// <summary>
/// Get Optimization profiles
/// </summary>
/// <param name="resultResponse">Failed response</param>
/// <returns>List of optimization profiles</returns>
public OptimizationProfilesResponse GetOptimizationProfiles(out ResultResponse resultResponse)
{
var response = GetJsonObjectFromAPI<OptimizationProfilesResponse>(new GenericParameters(),
R4MEInfrastructureSettingsV5.OptimizationProfilesList,
HttpMethodType.Get, false, true,
out resultResponse);

return response;
}

/// <summary>
/// Get Optimization profiles
/// </summary>
/// <returns>List of optimization profiles</returns>
public async Task<Tuple<OptimizationProfilesResponse, ResultResponse>> GetPodWorkflowsAsync()
{
var result = await GetJsonObjectFromAPIAsync<OptimizationProfilesResponse>(new GenericParameters(),
R4MEInfrastructureSettingsV5.OptimizationProfilesList,
HttpMethodType.Get,
null,
true,
false).ConfigureAwait(false);

return new Tuple<OptimizationProfilesResponse, ResultResponse>(result.Item1, result.Item2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,11 @@ public sealed class OptimizationParameters : GenericParameters
/// </summary>
[DataMember(Name = "order_territories")]
public OrderTerritories OrderTerritories { get; set; }

/// <summary>
/// Optimization profile ID
/// </summary>
[DataMember(Name = "optimization_profile_id", EmitDefaultValue = false)]
public string OptimizationProfileId { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,11 @@ public sealed class OptimizationParameters : GenericParameters
/// </summary>
[DataMember(Name = "depots", EmitDefaultValue = false)]
public Address[] Depots { get; set; }

/// <summary>
/// Optimization profile ID
/// </summary>
[DataMember(Name = "optimization_profile_id", EmitDefaultValue = false)]
public string OptimizationProfileId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Route4MeSDKLibrary.Managers;

namespace Route4MeSDK.Examples
{
public sealed partial class Route4MeExamples
{
public void GetOptimizationProfiles()
{
var route4Me = new OptimizationProfileManagerV5(ActualApiKey);

var optimizationProfiles = route4Me.GetOptimizationProfiles(out _);
}
}
}
6 changes: 6 additions & 0 deletions route4me-csharp-sdk/Route4MeSDKTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ static void Main(string[] args)

#endregion

#region Optimization Profiles

examples.GetOptimizationProfiles();

#endregion

#endregion
}
else // for a specifed example method
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using NUnit.Framework;
using Route4MeSDKLibrary.DataTypes.V5.OptimizationProfiles;
using Route4MeSDKLibrary.Managers;

namespace Route4MeSdkV5UnitTest.V5.OptimizationProfiles
{
[TestFixture]
public class OptimizationProfileManagerV5Tests
{
private static readonly string CApiKey = ApiKeys.ActualApiKey;

[Test]
public void GetPodWorkflowsTest()
{
var route4Me = new OptimizationProfileManagerV5(CApiKey);

var optimizationProfiles = route4Me.GetOptimizationProfiles(out _);

Assert.That(optimizationProfiles.GetType(), Is.EqualTo(typeof(OptimizationProfilesResponse)));
}
}
}

0 comments on commit c114540

Please sign in to comment.