Skip to content

Commit

Permalink
Prepare for 1.12.0-beta1 release
Browse files Browse the repository at this point in the history
Upgrades RestSharp to latest version
  • Loading branch information
paulirwin committed Dec 3, 2014
1 parent d34d941 commit a15adb4
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 77 deletions.
4 changes: 2 additions & 2 deletions src/Stripe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="RestSharp, Version=104.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="RestSharp, Version=105.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>
<HintPath>..\packages\RestSharp.105.0.1\lib\net4\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
14 changes: 7 additions & 7 deletions src/Stripe.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<package>
<metadata>
<id>Stripe</id>
<version>1.11.0</version>
<version>1.12.0-beta1</version>
<title>Stripe</title>
<authors>Nick Berardi</authors>
<authors>Nick Berardi, Paul Irwin</authors>
<owners>Stripe, Inc</owners>
<description>Stripe is a simple, developer-friendly way to accept payments online. We believe that enabling transactions on the web is a problem rooted in code, not finance, and we want to help put more websites in business.</description>
<summary>Stripe is a simple, developer-friendly way to accept payments online. We believe that enabling transactions on the web is a problem rooted in code, not finance, and we want to help put more websites in business.</summary>
<language>en-US</language>
<projectUrl>https://github.com/hoppio/stripe-dotnet</projectUrl>
<licenseUrl>https://github.com/hoppio/stripe-dotnet/raw/master/LICENSE.txt</licenseUrl>
<iconUrl>https://github.com/hoppio/stripe-dotnet/raw/master/nuget/Stripe.Logo.png</iconUrl>
<projectUrl>https://github.com/nberardi/stripe-dotnet</projectUrl>
<licenseUrl>https://github.com/nberardi/stripe-dotnet/raw/master/LICENSE.txt</licenseUrl>
<iconUrl>https://github.com/nberardi/stripe-dotnet/raw/master/nuget/Stripe.Logo.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<tags>payment gateway rest api .net40 .net45</tags>
<tags>stripe credit card payment gateway rest api .net40 .net45</tags>
<dependencies>
<dependency id="RestSharp" />
<dependency id="RestSharp" version="105.0.1" />
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Core" targetFramework="net40" />
Expand Down
136 changes: 69 additions & 67 deletions src/StripeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,83 +7,85 @@

namespace Stripe
{
/// <seealso href="https://stripe.com/docs/api"/>
public partial class StripeClient
{
public string ApiVersion { get; set; }
public string ApiEndpoint { get; set; }
public string ApiKey { get; private set; }
/// <seealso href="https://stripe.com/docs/api"/>
public partial class StripeClient
{
public string ApiVersion { get; set; }
public string ApiEndpoint { get; set; }
public string ApiKey { get; private set; }

private RestClient _client;
private RestClient _client;

public StripeClient(string apiKey)
{
ApiVersion = "v1";
ApiEndpoint = "https://api.stripe.com/";
ApiKey = apiKey;
public StripeClient(string apiKey)
{
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);
var version = assemblyName.Version;
// silverlight friendly way to get current version
var assembly = Assembly.GetExecutingAssembly();
AssemblyName assemblyName = new AssemblyName(assembly.FullName);
var version = assemblyName.Version;

_client = new RestClient();
_client.UserAgent = "stripe-dotnet/" + version;
_client.Authenticator = new StripeAuthenticator(apiKey);
_client.BaseUrl = String.Format("{0}{1}", ApiEndpoint, ApiVersion);
}
_client = new RestClient();
_client.UserAgent = "stripe-dotnet/" + version;
_client.Authenticator = new StripeAuthenticator(apiKey);
_client.BaseUrl = new Uri(String.Format("{0}{1}", ApiEndpoint, ApiVersion));
}

/// <summary>
/// Execute a manual REST request
/// </summary>
/// <typeparam name="T">The type of object to create and populate with the returned data.</typeparam>
/// <param name="request">The RestRequest to execute (will use client credentials)</param>
public StripeObject ExecuteObject(RestRequest request)
{
request.OnBeforeDeserialization = (resp) => {
// for individual resources when there's an error to make
// sure that RestException props are populated
if (((int)resp.StatusCode) >= 400)
request.RootElement = "";
};
/// <summary>
/// Execute a manual REST request
/// </summary>
/// <typeparam name="T">The type of object to create and populate with the returned data.</typeparam>
/// <param name="request">The RestRequest to execute (will use client credentials)</param>
public StripeObject ExecuteObject(RestRequest request)
{
request.OnBeforeDeserialization = (resp) =>
{
// for individual resources when there's an error to make
// sure that RestException props are populated
if (((int)resp.StatusCode) >= 400)
request.RootElement = "";
};

var response = _client.Execute(request);
var json = Deserialize(response.Content);
var obj = new StripeObject();
obj.SetModel(json);
var response = _client.Execute(request);
var json = Deserialize(response.Content);
var obj = new StripeObject();
obj.SetModel(json);

return obj;
}
return obj;
}

/// <summary>
/// Execute a manual REST request
/// </summary>
/// <typeparam name="T">The type of object to create and populate with the returned data.</typeparam>
/// <param name="request">The RestRequest to execute (will use client credentials)</param>
public StripeArray ExecuteArray(RestRequest request)
{
request.OnBeforeDeserialization = (resp) => {
// for individual resources when there's an error to make
// sure that RestException props are populated
if (((int)resp.StatusCode) >= 400)
request.RootElement = "";
};
/// <summary>
/// Execute a manual REST request
/// </summary>
/// <typeparam name="T">The type of object to create and populate with the returned data.</typeparam>
/// <param name="request">The RestRequest to execute (will use client credentials)</param>
public StripeArray ExecuteArray(RestRequest request)
{
request.OnBeforeDeserialization = (resp) =>
{
// for individual resources when there's an error to make
// sure that RestException props are populated
if (((int)resp.StatusCode) >= 400)
request.RootElement = "";
};

var response = _client.Execute(request);
var json = Deserialize(response.Content);
var obj = new StripeArray();
obj.SetModel(json);
var response = _client.Execute(request);
var json = Deserialize(response.Content);
var obj = new StripeArray();
obj.SetModel(json);

return obj;
}
return obj;
}

private IDictionary<string, object> Deserialize(string input)
{
if (String.IsNullOrEmpty(input))
return null;
private IDictionary<string, object> Deserialize(string input)
{
if (String.IsNullOrEmpty(input))
return null;

var serializer = new JavaScriptSerializer();
return serializer.Deserialize<IDictionary<string, object>>(input);
}
}
var serializer = new JavaScriptSerializer();
return serializer.Deserialize<IDictionary<string, object>>(input);
}
}
}
2 changes: 1 addition & 1 deletion src/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="RestSharp" version="104.1" targetFramework="net40" />
<package id="RestSharp" version="105.0.1" targetFramework="net40" />
</packages>

0 comments on commit a15adb4

Please sign in to comment.