Skip to content

Commit

Permalink
Make ctor overloaded for api version, only send if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Jul 7, 2015
1 parent 998b345 commit 32bcf33
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/StripeClient.cs
Expand Up @@ -15,13 +15,17 @@ public partial class StripeClient

private readonly RestClient _client;

public StripeClient(string apiKey, string apiVersion = null)
public StripeClient(string apiKey)
: this(apiKey, null)
{
}

public StripeClient(string apiKey, string apiVersion)
{
ApiVersion = "v1";
ApiEndpoint = "https://api.stripe.com/";
ApiKey = apiKey;



// silverlight friendly way to get current version
var assembly = Assembly.GetExecutingAssembly();
AssemblyName assemblyName = new AssemblyName(assembly.FullName);
Expand All @@ -31,7 +35,9 @@ public StripeClient(string apiKey, string apiVersion = null)
_client.UserAgent = "stripe-dotnet/" + version;
_client.Authenticator = new StripeAuthenticator(apiKey);
_client.BaseUrl = new Uri(String.Format("{0}{1}", ApiEndpoint, ApiVersion));
_client.AddDefaultParameter("Stripe-Version", apiVersion.HasValue() ? apiVersion : "2015-04-07", ParameterType.HttpHeader);

if (apiVersion.HasValue())
_client.AddDefaultParameter("Stripe-Version", apiVersion, ParameterType.HttpHeader);
}

/// <summary>
Expand Down

0 comments on commit 32bcf33

Please sign in to comment.