Skip to content

Commit

Permalink
Created and added the first methods of the Adapter module, allowing t…
Browse files Browse the repository at this point in the history
…o change adapter properties.

Still needs to be tested
  • Loading branch information
sidewinder94 committed Nov 11, 2019
1 parent de6d120 commit eac4cb9
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 6 deletions.
69 changes: 69 additions & 0 deletions SpeedifyCliWrapper/Modules/Adapter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using SpeedifyCliWrapper.ReturnTypes;
using System;
using System.Collections.Generic;
using System.Text;

namespace SpeedifyCliWrapper.Modules
{
public class Adapter
{
private Speedify _wrapper;
private const string _moduleName = "adapter";

public Adapter(Speedify wrapper)
{
this._wrapper = wrapper;
}

/// <summary>
/// Defines a daily data limit for a specified adapter.
/// </summary>
/// <param name="adapter">The adapter to set the limit on</param>
/// <param name="dataUsage">The limit in bytes, <code>null</code> is unlimited, default is null</param>
/// <param name="timeout">Timeout for the command, default 60</param>
/// <returns>An updated <see cref="SpeedifyAdapter"/> object</returns>
public SpeedifyAdapter DailyDataLimit(SpeedifyAdapter adapter, long? dataUsage = null, int timeout = 60)
{
string value = "unlimited";

if(dataUsage.HasValue)
{
value = dataUsage.ToString();
}

return this._wrapper.RunSpeedifyCommand<SpeedifyAdapter>(timeout, args: new[] { Adapter._moduleName, "datalimit", "daily", adapter.AdapterId.ToString(), value });
}

/// <summary>
/// Increase the daily data cap for today only
/// </summary>
/// <param name="adapter">The adapter to increase the limit on</param>
/// <param name="additionalData">Byte count to add to the limit</param>
/// <param name="timeout">Timeout for the command, default 60</param>
/// <returns>An updated <see cref="SpeedifyAdapter"/> object</returns>
public SpeedifyAdapter DailyDataBoost(SpeedifyAdapter adapter, long additionalData, int timeout = 60)
{
return this._wrapper.RunSpeedifyCommand<SpeedifyAdapter>(timeout, args: new[] { Adapter._moduleName, "datalimit", "dailyboost", adapter.AdapterId.ToString(), additionalData.ToString() });
}

/// <summary>
/// Defines a daily data limit for a specified adapter.
/// </summary>
/// <param name="adapter">The adapter to set the limit on</param>
/// <param name="dataUsage">The limit in bytes, <code>null</code> is unlimited, default is null</param>
/// <param name="dayOfReset">day of the month to reset on, 0 for last 30 days, default : 0</param>
/// <param name="timeout">Timeout for the command, default 60</param>
/// <returns>An updated <see cref="SpeedifyAdapter"/> object</returns>
public SpeedifyAdapter MonthlyDataLimit(SpeedifyAdapter adapter, long? dataUsage = null, int dayOfReset = 0,int timeout = 60)
{
string value = "unlimited";

if (dataUsage.HasValue)
{
value = dataUsage.ToString();
}

return this._wrapper.RunSpeedifyCommand<SpeedifyAdapter>(timeout, args: new[] { Adapter._moduleName, "datalimit", "monthly", adapter.AdapterId.ToString(), value, value == "unlimited" ? "" : dayOfReset.ToString() });
}
}
}
1 change: 1 addition & 0 deletions SpeedifyCliWrapper/ReturnTypes/SpeedifyAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Newtonsoft.Json;
using SpeedifyCliWrapper.Converters;
using SpeedifyCliWrapper.Enums;
using SpeedifyCliWrapper.Modules;

namespace SpeedifyCliWrapper.ReturnTypes
{
Expand Down
9 changes: 8 additions & 1 deletion SpeedifyCliWrapper/Speedify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,23 @@ public string CliPath
}
}

private Lazy<Show> _show;
private readonly Lazy<Show> _show;
private readonly Lazy<Adapter> _adapter;

public Show Show
{
get => this._show.Value;
}

public Adapter Adapter
{
get => this._adapter.Value;
}

public Speedify()
{
this._show = new Lazy<Show>(() => new Show(this));
this._adapter = new Lazy<Adapter>(() => new Adapter(this));
}

#region Run Command Methods
Expand Down
12 changes: 7 additions & 5 deletions SpeedifyCliWrapper/SpeedifyCliWrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
<TargetFrameworks>netstandard2.0;net462;net45</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.10-pre</Version>
<AssemblyVersion>1.0.10.0</AssemblyVersion>
<FileVersion>1.0.10.0</FileVersion>
<PackageReleaseNotes>Finished with the show module.
The enums are now nullable in case an unexpected value occurs</PackageReleaseNotes>
<Version>1.0.11-pre</Version>
<AssemblyVersion>1.0.11.0</AssemblyVersion>
<FileVersion>1.0.11.0</FileVersion>
<PackageReleaseNotes>Created and added the first methods of the Adapter module, allowing to change adapter properties.
Still needs to be tested</PackageReleaseNotes>
<Authors>Antoine-Ali Zarrouk</Authors>
<Company />
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit eac4cb9

Please sign in to comment.