Skip to content

Commit

Permalink
Merge pull request #5 from dmalberto/master
Browse files Browse the repository at this point in the history
Add new endpoints
  • Loading branch information
WhinterGoncalves authored Aug 28, 2019
2 parents 9a56d8a + c069b1a commit 611a461
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.0.9

- Added: new endpoint (OneStep)
- Updated: docs

# 1.0.8

- Added: TLS 1.2 support
Expand Down
2 changes: 2 additions & 0 deletions Gerencianet.SDK.Examples/Gerencianet.SDK.Examples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
<Compile Include="ResendParcel.cs" />
<Compile Include="UpdateBillet.cs" />
<Compile Include="UpdateCarnetMetadata.cs" />
<Compile Include="OneStepBankingBillet.cs" />
<Compile Include="OneStepCreditCard.cs" />
<Compile Include="UpdateChargeMetadata.cs" />
<Compile Include="UpdateParcel.cs" />
<Compile Include="UpdateSubscriptionMetadata.cs" />
Expand Down
60 changes: 60 additions & 0 deletions Gerencianet.SDK.Examples/OneStepBankingBillet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;

namespace Gerencianet.SDK.Examples
{
class OneStepBankingBillet
{
public static void Execute()
{
dynamic endpoints = new Endpoints(Credentials.Default.ClientId, Credentials.Default.ClientSecret,
Credentials.Default.Sandbox);

var body = new
{
items = new[]
{
new
{
name = "Product 1",
value = 1000,
amount = 2
}
},
shippings = new[]
{
new
{
name = "Default Shipping Cost",
value = 100
}
},
payment = new
{
banking_billet = new
{
expire_at = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"),
customer = new
{
name = "Gorbadoc Oldbuck",
email = "oldbuckaa@gerencianet.com.br",
cpf = "94271564656",
birth = "1977-01-15",
phone_number = "5144916523"
}
}
}
};

try
{
var response = endpoints.OneStep(null, body);
Console.WriteLine(response);
}
catch (GnException e)
{
Console.WriteLine(e.ErrorType);
Console.WriteLine(e.Message);
}
}
}
}
62 changes: 62 additions & 0 deletions Gerencianet.SDK.Examples/OneStepCreditCard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
namespace Gerencianet.SDK.Examples
{
class OneStepCreditCard
{
public static void Execute()
{
dynamic endpoints = new Endpoints(Credentials.Default.ClientId, Credentials.Default.ClientSecret, Credentials.Default.Sandbox);
var body = new
{
items = new[] {
new {
name = "Product 1",
value = 590,
amount = 2
}
},
shippings = new[] {
new {
name = "Default Shipping Cost",
value = 10
}
},
payment = new
{
credit_card = new
{
installments = 1,
payment_token = "7d0a3fe0f0c9caab4f3b6578317a9d7e8ed6303f",
billing_address = new
{
street = "Av. JK",
number = 909,
neighborhood = "Bauxita",
zipcode = "35400000",
city = "Ouro Preto",
state = "MG"
},
customer = new
{
name = "Gorbadoc Oldbuck",
email = "oldbuck@gerencianet.com.br",
cpf = "04267484171",
birth = "1977-01-15",
phone_number = "5144916523"
}
}
}
};
try
{
var response = endpoints.OneStep(null, body);
Console.WriteLine(response);
}
catch (GnException e)
{
Console.WriteLine(e.ErrorType);
Console.WriteLine(e.Message);
}
}
}
}
2 changes: 1 addition & 1 deletion Gerencianet.SDK/Endpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Endpoints : DynamicObject
{
private const string ApiBaseURL = "https://api.gerencianet.com.br/v1";
private const string ApiBaseSandboxURL = "https://sandbox.gerencianet.com.br/v1";
private const string Version = "1.0.8";
private const string Version = "1.0.9";

private JObject endpoints;
private string clientId;
Expand Down
6 changes: 5 additions & 1 deletion Gerencianet.SDK/endpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,9 @@
"SettleCarnetParcel": {
"route": "/carnet/:id/parcel/:parcel/settle",
"method": "PUT"
}
},
"OneStep": {
"route": "/charge/one-step",
"method": "POST"
}
}
11 changes: 8 additions & 3 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ provided by [Gerencianet](http://gerencianet.com.br).

## Installation

From Visual Studio package manager: Search for ```Gerencianet.SDK```
From Visual Studio package manager:

From command-line with NuGet:
```bash
PM> Install-Package Gerencianet.SDK -Version 1.0.8
```

From .NET Cli:

```bash
$ nuget install Gerencianet.SDK
> dotnet add package Gerencianet.SDK --version 1.0.8
```

### Tested with
```
dotnet 4.0.0
Expand Down

0 comments on commit 611a461

Please sign in to comment.