Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Master from Develop #93

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Client .Net de acesso aos principais recursos da Api da **IUGU**

### Configuração

* Em seu arquivo de configuração (.config), é necessário adicionar a apiKey encontrada no seu painel [administrativo da IUGU](https://iugu.com/a/administration), em *Administração* > *Configuração de Contas*. Nesta tela você encontra seu *ID da Conta*
* Em algum *StartUp* de seu projeto, é necessário adicionar a apiKey encontrada no seu painel [administrativo da IUGU](https://iugu.com/a/administration), em *Administração* > *Configuração de Contas*. Nesta tela você encontra seu *ID da Conta*

```xml
<appSettings>
<add key="iuguApiKey" value="SUA_APP_KEY_DA_IUGU" />
...
</appSettings>
```csharp
IuguClient.Init(new IuguClientProperties()
{
ApiKey = "SUA_APP_KEY_DA_IUGU"
});
```
### Documentação completa da API
A referência completa da Api pode ser encontrada em [IUGU Api](https://iugu.com/referencias/api)
Expand All @@ -46,6 +46,10 @@ public class AnyClass
```

### Informações Adicionais
* A partir da versão 1.8.5, houve um downgrade da **versão miníma do .Net framework para a versão 4.5** e uma mudança nas dependências.Essas alterações não provocam necessáriamente quebra de versões, a não ser que exista um conflito de dependências.
* A partir da versão 2.0, o projeto foi reestruturado para ser compilado de forma *retrocompatível* com **.NET Standard 2.0** e **.NET Framework 4.5**.
Essas alterações não provocam nenhuma quebra de versão em atuais projetos **.NET Framework** e consequentemente adiciona suporte nativo ao **.NET Standard 2.0**.

* A partir da versão 2.0, o cliente **NÃO** é mais configurado através de arquivos `.config`, e sim através do factory `IuguClient.Init`, conforme exemplo acima.

* A partir da versão 1.8.5, houve um downgrade da **versão miníma do .Net framework para a versão 4.5** e uma mudança nas dependências.
Essas alterações não provocam necessáriamente quebra de versões, a não ser que exista um conflito de dependências.
17 changes: 17 additions & 0 deletions iugu.net.IntegratedTests/GlobalSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using NUnit.Framework;

namespace iugu.net.IntegratedTests
{
[SetUpFixture]
public class GlobalSetup
{
[OneTimeSetUp]
public void IuguClientConfig()
{
IuguClient.Init(new IuguClientProperties()
{
ApiKey = "74c265aedbfaea379bc0148fae9b5526"
});
}
}
}
1 change: 0 additions & 1 deletion iugu.net.IntegratedTests/app.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="iuguApiKey" value="74c265aedbfaea379bc0148fae9b5526" />
<!-- Supported values: nunit, xunit, mstest, mspec, mbunit and gallio -->
<add key="FluentAssertions.TestFramework" value="nunit" />
</appSettings>
Expand Down
6 changes: 3 additions & 3 deletions iugu.net.IntegratedTests/iugu.net.IntegratedTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net45\FluentAssertions.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll</HintPath>
Expand All @@ -67,6 +66,7 @@
<Compile Include="CustomerIntegratedTests.cs" />
<Compile Include="DataBuilders\PayerModelDataBuilder.cs" />
<Compile Include="ErrorResponseIntegratedTests.cs" />
<Compile Include="GlobalSetup.cs" />
<Compile Include="InvoiceIntegratedTests.cs" />
<Compile Include="MarketPlaceIntegratedTests.cs" />
<Compile Include="PaymentTokenIntegratedTests.cs" />
Expand Down
2 changes: 1 addition & 1 deletion iugu.net.IntegratedTests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="AutoFixture" version="3.50.2" targetFramework="net45" />
<package id="coveralls.io" version="1.3.4" targetFramework="net45" />
<package id="FluentAssertions" version="4.19.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net45" />
<package id="NUnit" version="3.6.0" targetFramework="net45" />
<package id="NUnit.Console" version="3.6.0" targetFramework="net45" />
<package id="NUnit.ConsoleRunner" version="3.6.0" targetFramework="net45" />
Expand Down
1 change: 0 additions & 1 deletion iugu.net.UnitTests/app.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="iuguApiKey" value="74c265aedbfaea379bc0148fae9b5526" />
<!-- Supported values: nunit, xunit, mstest, mspec, mbunit and gallio -->
<add key="FluentAssertions.TestFramework" value="nunit" />
</appSettings>
Expand Down
5 changes: 2 additions & 3 deletions iugu.net.UnitTests/iugu.net.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net45\FluentAssertions.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net45\nunit.framework.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion iugu.net.UnitTests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="AutoFixture" version="3.50.2" targetFramework="net45" />
<package id="coveralls.io" version="1.3.4" targetFramework="net45" />
<package id="FluentAssertions" version="4.19.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net45" />
<package id="NUnit" version="3.6.0" targetFramework="net45" />
<package id="NUnit.Console" version="3.6.0" targetFramework="net45" />
<package id="NUnit.ConsoleRunner" version="3.6.0" targetFramework="net45" />
Expand Down
4 changes: 4 additions & 0 deletions iugu.net/Entity/InvoiceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public class InvoiceModel
public bool early_payment_discount { get; set; }
public List<EarlyPaymentDiscounts> early_payment_discounts { get; set; }
public List<Logs> logs { get; set; }
public string payable_with { get; set; }
public string commission_cents { get; set; }
public string customer_ref { get; set; }
public string customer_name { get; set; }
}

// TODO: Precisa de refatoração, nomes fora do padrão .Net, sem documentação também
Expand Down
33 changes: 33 additions & 0 deletions iugu.net/IuguClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace iugu.net
{
/// <summary>
/// Iugu.Net Factory
/// </summary>
public static class IuguClient
{
/// <summary>
/// Propriedades do cliente.
/// </summary>
public static IuguClientProperties Properties { get; internal set; }

/// <summary>
/// Atualiza as propriedades do cliente.
/// </summary>
/// <param name="properties"></param>
public static void Init(IuguClientProperties properties)
{
Properties = properties;
}
}

/// <summary>
/// Propriedades do cliente.
/// </summary>
public class IuguClientProperties
{
/// <summary>
/// API Key encontrada no painel administrativo da IUGU.
/// </summary>
public string ApiKey { get; set; }
}
}
3 changes: 1 addition & 2 deletions iugu.net/Lib/APIResource.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Newtonsoft.Json;
using System;
using System.Linq;
using System.Configuration;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
Expand Down Expand Up @@ -61,7 +60,7 @@ public APIResource(IHttpClientWrapper customClient, JsonSerializerSettings custo
_version = "1.0.5";
_apiVersion = "v1";
_endpoint = "https://api.iugu.com";
_apiKey = ConfigurationManager.AppSettings["iuguApiKey"];
_apiKey = IuguClient.Properties.ApiKey;

if (string.IsNullOrEmpty(_apiKey))
{
Expand Down
8 changes: 8 additions & 0 deletions iugu.net/Lib/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using iugu.net.Response;

namespace iugu.net.Lib
{
Expand Down Expand Up @@ -43,6 +44,13 @@ public async Task<CustomerModel> GetAsync(string id)
var retorno = await GetAsync<CustomerModel>(id).ConfigureAwait(false);
return retorno;
}

public async Task<PaggedResponseMessage<CustomerModel>> GetAllAsync(string customApiToken, QueryStringFilter filter)
{
var queryStringFilter = filter?.ToQueryStringUrl();
var retorno = await GetAsync<PaggedResponseMessage<CustomerModel>>(null, queryStringFilter, customApiToken).ConfigureAwait(false);
return retorno;
}

public async Task<CustomerModel> GetFromCustomApiTokenAsync(string customApiToken)
{
Expand Down
36 changes: 0 additions & 36 deletions iugu.net/Properties/AssemblyInfo.cs

This file was deleted.

2 changes: 1 addition & 1 deletion iugu.net/Request/AccountConfigurationRequestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class BankSlipOptions
/// <summary>
/// Dias de Vencimento Extras no Boleto (Ex: 2)
/// </summary>
[JsonProperty("extra_due ")]
[JsonProperty("extra_due")]
public int? ExtraDueDays { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion iugu.net/Request/AccountRequestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class AccountRequestMessage
/// <summary>
/// Percentual de comissionamento enviado para a conta que gerencia o marketplace (Valor entre 0 e 70)
/// </summary>
[JsonProperty("commission_percent ")]
[JsonProperty("commission_percent")]
public int? CommissionPercent { get; set; }
}
}
4 changes: 2 additions & 2 deletions iugu.net/Request/ChargeRequestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public class ChargeRequestMessage
/// <summary>
/// ID do Cliente. Utilizado para vincular a Fatura a um Cliente - Opcional
/// </summary>
[JsonProperty("customer_id ")]
[JsonProperty("customer_id")]
public string CustomerId { get; set; }

/// <summary>
/// ID da Fatura a ser utilizada para pagamento - Opcional
/// </summary>
[JsonProperty("invoice_id ")]
[JsonProperty("invoice_id")]
public string InvoiceId { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion iugu.net/Request/InvoiceRequestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class InvoiceRequestMessage
/// <summary>
/// (opcional) Cliente é redirecionado para essa URL se a Fatura que estiver acessando estiver expirada
/// </summary>
[JsonProperty("expired_url ")]
[JsonProperty("expired_url")]
public string ExpiredUrl { get; set; }

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions iugu.net/Request/SubscriptionRequestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,27 @@ public SubscriptionRequestMessage(string customerId)
/// <summary>
/// Apenas Cria a Assinatura se a Cobrança for bem sucedida. Isso só funciona caso o cliente já tenha uma forma de pagamento padrão cadastrada
/// </summary>
[JsonProperty("only_on_charge_success ")]
[JsonProperty("only_on_charge_success")]
public bool? OnlyOnChargeSuccess { get; set; }

/// <summary>
/// Método de pagamento que será disponibilizado para as Faturas desta Assinatura (all, credit_card ou bank_slip).
/// Obs: Dependendo do valor, este atributo será herdado, pois a prioridade é herdar o valor atribuído ao Plano desta Assinatura;
/// Caso este esteja atribuído o valor ‘all’, o sistema considerará o payable_with da Assinatura; se não, o sistema considerará o payable_with do Plano
/// </summary>
[JsonProperty("payable_with ")]
[JsonProperty("payable_with")]
public string PayableWith { get; set; }

/// <summary>
/// É uma assinatura baseada em créditos
/// </summary>
[JsonProperty("credits_based ")]
[JsonProperty("credits_based")]
public bool? IsCreditBased { get; set; }

/// <summary>
/// Preço em centavos da recarga para assinaturas baseadas em crédito
/// </summary>
[JsonProperty("price_cents ")]
[JsonProperty("price_cents")]
public int? PriceCents { get; set; }

/// <summary>
Expand Down
11 changes: 0 additions & 11 deletions iugu.net/app.config

This file was deleted.

Loading