Skip to content

Commit

Permalink
Merge pull request iugu#77 from erickmcarvalho/develop
Browse files Browse the repository at this point in the history
Reestruturação do projeto para suporte ao .NET Standard
  • Loading branch information
rscouto authored Nov 11, 2019
2 parents 6a2256d + 44b0be4 commit 12920ef
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 180 deletions.
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
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
36 changes: 0 additions & 36 deletions iugu.net/Properties/AssemblyInfo.cs

This file was deleted.

11 changes: 0 additions & 11 deletions iugu.net/app.config

This file was deleted.

129 changes: 20 additions & 109 deletions iugu.net/iugu.net.csproj
Original file line number Diff line number Diff line change
@@ -1,41 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{35EE3CD1-39DE-4401-8523-EB94774CBD3B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>iugu.net</RootNamespace>
<AssemblyName>iugu.net</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<PackageId>Iugu.Net</PackageId>
<AssemblyTitle>Iugu.Net</AssemblyTitle>
<AssemblyName>Iugu.Net</AssemblyName>
<Copyright>Copyright (c) 2018, IUGU</Copyright>
<Company>IUGU</Company>
<Product>Iugu.Net</Product>
<Version>2.0.0</Version>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0.0</FileVersion>
<Description>Cliente .Net para a API da IUGU</Description>
<RepositoryUrl>https://github.com/iugu/iugu-net</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<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>

<ItemGroup Condition="$(TargetFramework) == 'net45'">
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
Expand All @@ -47,79 +28,9 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>

<ItemGroup>
<Compile Include="Constants.cs" />
<Compile Include="Entity\AccountModel.cs" />
<Compile Include="Entity\ChargeModel.cs" />
<Compile Include="Entity\AddressModel.cs" />
<Compile Include="Entity\CustomerModel.cs" />
<Compile Include="Entity\DataEntryModel.cs" />
<Compile Include="Entity\InvoiceItem.cs" />
<Compile Include="Entity\InvoiceModel.cs" />
<Compile Include="Entity\PayerModel.cs" />
<Compile Include="Entity\PaymentInfoModel.cs" />
<Compile Include="Entity\PaymentMethodModel.cs" />
<Compile Include="Entity\PlanModel.cs" />
<Compile Include="Entity\SubscriptionModel.cs" />
<Compile Include="Entity\TokenModel.cs" />
<Compile Include="Entity\TransferModel.cs" />
<Compile Include="Enums.cs" />
<Compile Include="Filters\FilterOptions.cs" />
<Compile Include="JsonCustomConverters\CustomConverters.cs" />
<Compile Include="Lib\Account.cs" />
<Compile Include="Lib\APIResource.cs" />
<Compile Include="Lib\Charge.cs" />
<Compile Include="Lib\Customer.cs" />
<Compile Include="Lib\FinancialTransaction.cs" />
<Compile Include="Lib\Invoice.cs" />
<Compile Include="Lib\MarketPlace.cs" />
<Compile Include="Lib\PaymentMethod.cs" />
<Compile Include="Lib\PaymentToken.cs" />
<Compile Include="Lib\Plans.cs" />
<Compile Include="Lib\Reports.cs" />
<Compile Include="Lib\StandardHttpClient.cs" />
<Compile Include="Lib\Subscription.cs" />
<Compile Include="Lib\Transfers.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Request\AccountConfigurationRequestMessage.cs" />
<Compile Include="Request\AccountRequestMessage.cs" />
<Compile Include="Request\BankVerificationRequestMessage.cs" />
<Compile Include="Request\ChargeRequestMessage.cs" />
<Compile Include="Request\CustomerRequestMessage.cs" />
<Compile Include="Request\FinancialTransactionRequestMessage.cs" />
<Compile Include="Request\InvoiceDuplicateRequestMessage.cs" />
<Compile Include="Request\InvoiceRequestMessage.cs" />
<Compile Include="Request\PaymentTokenRequest.cs" />
<Compile Include="Request\PlanRequestMessage.cs" />
<Compile Include="Request\SubscriptionRequestMessage.cs" />
<Compile Include="Request\VerifyAccountRequestMessage.cs" />
<Compile Include="Response\AccountRequestWithdrawResponse.cs" />
<Compile Include="Response\AccountResponseMessage.cs" />
<Compile Include="Response\ChargeResponseMessage.cs" />
<Compile Include="Response\ErrorResponseMessage.cs" />
<Compile Include="Response\FinancialTransactionResponse.cs" />
<Compile Include="Response\GetAccountResponseMessage.cs" />
<Compile Include="Response\MarketplaceAccoutsResponse.cs" />
<Compile Include="Response\PaggedResponseMessage.cs" />
<Compile Include="Response\PaymentTokenResponse.cs" />
<Compile Include="Response\RequestWithdrawResponseMessage.cs" />
<Compile Include="Response\SimpleResponseMessage.cs" />
<Compile Include="Response\TransfersReportResponseMessage.cs" />
<Compile Include="Response\VerifyAccountResponseMessage.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
5 changes: 0 additions & 5 deletions iugu.net/packages.config

This file was deleted.

0 comments on commit 12920ef

Please sign in to comment.