Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Removed Client Builder #4

Merged
merged 1 commit into from

2 participants

@maddenpj

A ClientBuilder class was used to create Tempodb clients that became unnecessary due to C# getting the default arguments feature. ClientBuilder was only to give sensible defaults, replaced by default arguments.

Also fixed Update Tests (They weren't respecting sending the whole series to server)

@myagley
Owner

I'll merge this time. But, in the future we should split these into two changes:

  • Remove ClientBuilder
  • Update tests
@myagley myagley merged commit 8ac3d06 into master
@myagley myagley deleted the remove_builder branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 2, 2013
  1. @maddenpj

    Removed Client Builder

    maddenpj authored
This page is out of date. Refresh to see the latest.
View
3  Client.Tests/SeriesTests.cs
@@ -303,6 +303,7 @@ public void SmokeTest()
var seriesResponse = new Series
{
Id = "series-id",
+ Key = "series-key",
Tags = new List<string> { "updated" }
};
@@ -321,6 +322,7 @@ public void RequestMethod()
var seriesResponse = new Series
{
Id = "series-id",
+ Key = "series-key",
Tags = new List<string> { "updated" }
};
@@ -338,6 +340,7 @@ public void RequestUrl()
var seriesResponse = new Series
{
Id = "series-id",
+ Key = "series-key",
Tags = new List<string> { "updated" }
};
View
9 Client.Tests/TestCommon.cs
@@ -11,14 +11,7 @@ class TestCommon
{
public static Client GetClient(RestClient restClient = null)
{
- return new ClientBuilder()
- .Host("api.tempo-db.com")
- .Key("api-key")
- .Port(443)
- .Secret("api-secret")
- .Secure(true)
- .RestClient(restClient)
- .Build();
+ return new Client("api-key", "api-secret", restClient: restClient);
}
public static Mock<RestClient> GetMockRestClient<T>(T response) where T : new()
View
2  Client/Client.cs
@@ -40,7 +40,7 @@ public class Client
/// <param name="version"> The API version</param>
/// <param name="secure"> Uses http if false, https if true </param>
/// <param name="restClient"> Optional Rest Client. </param>
- public Client(string key, string secret, string host, int port, string version, bool secure, RestClient restClient = null)
+ public Client(string key, string secret, string host = "api.tempo-db.com", int port = 443, string version = "v1", bool secure = true, RestClient restClient = null)
{
_key = key;
_secret = secret;
View
115 Client/ClientBuilder.cs
@@ -1,115 +0,0 @@
-using RestSharp;
-
-namespace Client
-{
- /// <summary>
- /// A builder object for a Client instance.
- /// <p/>
- /// Typical use:
- /// <p/>
- /// <pre>
- /// {@code
- /// Client client = new ClientBuilder()
- /// .Key("your-api-key")
- /// .Secret("your-api-secret")
- /// .Host("api.tempo-db.com")
- /// .Port(443)
- /// .Version("v1")
- /// .Secure(true)
- /// .Build();
- /// }
- /// </pre>
- /// </summary>
- public class ClientBuilder
- {
-
- private string _keyRenamed;
- private string _secretRenamed;
- private string _hostRenamed = "api.tempo-db.com";
- private int _portRenamed = 443;
- private bool _secureRenamed = true;
- private string _versionRenamed = "v1";
- private RestClient _restClientRenamed = null;
-
- /// <summary>
- /// Returns the built Client instance
- /// </summary>
- /// <returns> A new Client instance </returns>
- public Client Build()
- {
- return new Client(_keyRenamed, _secretRenamed, _hostRenamed, _portRenamed, _versionRenamed, _secureRenamed, _restClientRenamed);
- }
-
- /// <summary>
- /// Sets the api key for the client instance.
- /// </summary>
- /// <param name="key"> The api key for the database being accessed </param>
- public ClientBuilder Key(string key)
- {
- _keyRenamed = key;
- return this;
- }
-
- /// <summary>
- /// Sets the api secret for the client instance.
- /// </summary>
- /// <param name="secret"> The api secret for the database being accessed </param>
- public ClientBuilder Secret(string secret)
- {
- _secretRenamed = secret;
- return this;
- }
-
- /// <summary>
- /// Sets the api host for the client instance.
- /// </summary>
- /// <param name="host"> The hostname of the server being accessed </param>
- public ClientBuilder Host(string host)
- {
- _hostRenamed = host;
- return this;
- }
-
- /// <summary>
- /// Sets the api port for the client instance.
- /// </summary>
- /// <param name="port"> The port of the server being accessed </param>
- public ClientBuilder Port(int port)
- {
- _portRenamed = port;
- return this;
- }
-
-
- /// <summary>
- /// Sets the api version for the client instance.
- /// </summary>
- /// <param name="version">The api version to use </param>
- public ClientBuilder Version(string version)
- {
- _versionRenamed = version;
- return this;
- }
-
-
- /// <summary>
- /// Sets the protocol being used.
- /// </summary>
- /// <param name="secure"> true = https, false = http </param>
- public ClientBuilder Secure(bool secure)
- {
- _secureRenamed = secure;
- return this;
- }
-
- /// <summary>
- /// Sets the rest client
- /// </summary>
- /// <param name="restClient"> RestClient </param>
- public ClientBuilder RestClient(RestClient restClient)
- {
- _restClientRenamed = restClient;
- return this;
- }
- }
-}
View
1  Client/TempoClient.csproj
@@ -50,7 +50,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Client.cs" />
- <Compile Include="ClientBuilder.cs" />
<Compile Include="JsonSerializer.cs" />
<Compile Include="Model\BulkDataSet.cs" />
<Compile Include="Model\BulkIdPoint.cs" />
Something went wrong with that request. Please try again.