Skip to content

Commit

Permalink
Prepare the project for publishing as NugetPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaumov committed Sep 23, 2021
1 parent ccfcf67 commit 9160423
Show file tree
Hide file tree
Showing 19 changed files with 1,200 additions and 239 deletions.
7 changes: 0 additions & 7 deletions Acumatica REST API Client.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.29503.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Acumatica REST API Example Console Application", "Acumatica REST API Console Application\Acumatica REST API Example Console Application.csproj", "{201508E8-B057-4EFB-AD9D-74C777339C42}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Acumatica.Auth", "Acumatica.Auth\Acumatica.Auth.csproj", "{5B17772D-1F76-4A4B-A3F7-8C8CFFA93E29}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Acumatica.RESTClient", "Acumatica.RESTClient\Acumatica.RESTClient.csproj", "{25008D3F-3D78-4BB9-B14B-0A792AE97892}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SOAPLikeWrapperForREST", "SOAPLikeWrapperForREST\SOAPLikeWrapperForREST.csproj", "{99541823-473A-46E8-AEC0-CE6250F00FE8}"
Expand Down Expand Up @@ -45,10 +43,6 @@ Global
{201508E8-B057-4EFB-AD9D-74C777339C42}.Debug|Any CPU.Build.0 = Debug|Any CPU
{201508E8-B057-4EFB-AD9D-74C777339C42}.Release|Any CPU.ActiveCfg = Release|Any CPU
{201508E8-B057-4EFB-AD9D-74C777339C42}.Release|Any CPU.Build.0 = Release|Any CPU
{5B17772D-1F76-4A4B-A3F7-8C8CFFA93E29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B17772D-1F76-4A4B-A3F7-8C8CFFA93E29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B17772D-1F76-4A4B-A3F7-8C8CFFA93E29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B17772D-1F76-4A4B-A3F7-8C8CFFA93E29}.Release|Any CPU.Build.0 = Release|Any CPU
{25008D3F-3D78-4BB9-B14B-0A792AE97892}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25008D3F-3D78-4BB9-B14B-0A792AE97892}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25008D3F-3D78-4BB9-B14B-0A792AE97892}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -106,7 +100,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5B17772D-1F76-4A4B-A3F7-8C8CFFA93E29} = {F0B2BD45-79AE-43AF-B737-3018CD95C6E3}
{4FDDE01D-C802-4E52-9458-B614B1C8EFAB} = {F0B2BD45-79AE-43AF-B737-3018CD95C6E3}
{638D4F3F-4496-44DC-8BAA-6C0F05516A22} = {F0B2BD45-79AE-43AF-B737-3018CD95C6E3}
{8F2FDE89-9542-487F-AFD9-40DA3704DF92} = {F0B2BD45-79AE-43AF-B737-3018CD95C6E3}
Expand Down
24 changes: 15 additions & 9 deletions Acumatica.RESTClient/Acumatica.RESTClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,28 @@ OpenAPI spec version: 3
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Api\BaseApi.cs" />
<Compile Include="Api\EntityAPI_Implementation.cs" />
<Compile Include="Api\FileApi.cs" />
<Compile Include="AcumaticaApi\AuthApi.cs" />
<Compile Include="AcumaticaApi\RootApi.cs" />
<Compile Include="BaseApi\BaseApi.cs" />
<Compile Include="BaseApi\EntityAPI_Implementation.cs" />
<Compile Include="AcumaticaApi\FileApi.cs" />
<Compile Include="Auxiliary\AuxiliaryEntityTypes.cs" />
<Compile Include="Client\ApiClient.cs" />
<Compile Include="Client\ApiException.cs" />
<Compile Include="Client\ApiResponse.cs" />
<Compile Include="Client\Configuration.cs" />
<Compile Include="Api\EntityAPI_Public.cs" />
<Compile Include="BaseApi\EntityAPI_Public.cs" />
<Compile Include="Client\ExceptionFactory.cs" />
<Compile Include="Client\IApiAccessor.cs" />
<Compile Include="Client\IReadableConfiguration.cs" />
<Compile Include="Client\OpenAPIDateConverter.cs" />
<Compile Include="Model\Entity.cs" />
<Compile Include="Model\EntityAction.cs" />
<Compile Include="Model\EntityActionWithParameters.cs" />
<Compile Include="Model\Entity_v3.cs" />
<Compile Include="Model\Entity_v4.cs" />
<Compile Include="Model\Credentials.cs" />
<Compile Include="Model\Endpoint.cs" />
<Compile Include="Model\EntityBase\Entity.cs" />
<Compile Include="Model\EntityBase\EntityAction.cs" />
<Compile Include="Model\EntityBase\EntityActionWithParameters.cs" />
<Compile Include="Model\EntityBase\Entity_v3.cs" />
<Compile Include="Model\EntityBase\Entity_v4.cs" />
<Compile Include="Model\FieldTypes\BooleanValue.cs" />
<Compile Include="Model\FieldTypes\ByteValue.cs" />
<Compile Include="Model\FieldTypes\CustomBooleanField.cs" />
Expand All @@ -101,6 +105,8 @@ OpenAPI spec version: 3
<Compile Include="Model\FieldTypes\StringValue.cs" />
<Compile Include="Model\FileLink.cs" />
<Compile Include="Model\HttpError.cs" />
<Compile Include="Model\Version.cs" />
<Compile Include="Model\VersionAndEndpoints.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
179 changes: 179 additions & 0 deletions Acumatica.RESTClient/AcumaticaApi/AuthApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
using Acumatica.Auth.Model;
using Acumatica.RESTClient.Api;
using Acumatica.RESTClient.Client;
using RestSharp;
using System;
using System.Net;


namespace Acumatica.Auth.Api
{
/// <summary>
/// Represents a collection of functions to interact with the Authorization endpoint
/// </summary>
public partial class AuthApi : BaseApi
{
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="AuthApi"/> class.
/// </summary>
/// <returns></returns>
public AuthApi(String basePath) : base(basePath)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="AuthApi"/> class
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <returns></returns>
public AuthApi(Configuration configuration) : base(configuration)
{ }
#endregion

#region Public Methods
public Configuration LogIn(string username, string password, string tenant = null, string branch = null, string locale = null)
{
var cookieContainer = new CookieContainer();
this.Configuration.ApiClient.RestClient.CookieContainer = cookieContainer;

this.AuthLogin(new Credentials(username, password, tenant, branch, locale));
// Console.WriteLine("Logged In...");
var configuration = new Configuration(this.Configuration.BasePath);

//share cookie container between API clients because we use different client for authentication and interaction with endpoint
configuration.ApiClient.RestClient.CookieContainer = this.Configuration.ApiClient.RestClient.CookieContainer;
return configuration;
}
/// <summary>
/// Logs in to the system.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="credentials"></param>
/// <returns></returns>
public void AuthLogin(Credentials credentials)
{
AuthLoginWithHttpInfo(credentials);
}
/// <summary>
/// Logs in to the system.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="credentials"></param>
/// <returns>Task of void</returns>
public async System.Threading.Tasks.Task AuthLoginAsync(Credentials credentials)
{
await AuthLoginAsyncWithHttpInfo(credentials);

}

/// <summary>
/// Logs out from the system.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <returns></returns>
public void AuthLogout()
{
AuthLogoutWithHttpInfo();
}
/// <summary>
/// Logs out from the system.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <returns>Task of void</returns>
public async System.Threading.Tasks.Task AuthLogoutAsync()
{
await AuthLogoutAsyncWithHttpInfo();

}
#endregion

#region Implementation
/// <summary>
/// Logs in to the system.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="credentials"></param>
/// <returns>ApiResponse of Object(void)</returns>
protected ApiResponse<Object> AuthLoginWithHttpInfo(Credentials credentials)
{
// verify the required parameter 'credentials' is set
if (credentials == null)
ThrowMissingParameter("AuthLogin", nameof(credentials));

var localVarPath = "/entity/auth/login";

// make the HTTP request
IRestResponse localVarResponse = (IRestResponse)this.Configuration.ApiClient.CallApi(localVarPath,
Method.POST, ComposeEmptyQueryParams(), ComposeBody(credentials), ComposeAcceptHeaders(HeaderContentType.None), ComposeEmptyFormParams(), ComposeEmptyFileParams(),
ComposeEmptyPathParams(), ComposeContentHeaders(HeaderContentType.Json | HeaderContentType.Xml | HeaderContentType.WwwForm));

VerifyResponse(localVarResponse, "AuthLogin");

return GetResponseHeaders(localVarResponse);
}

/// <summary>
/// Logs in to the system.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="credentials"></param>
/// <returns>Task of ApiResponse</returns>
protected async System.Threading.Tasks.Task<ApiResponse<Object>> AuthLoginAsyncWithHttpInfo(Credentials credentials)
{
// verify the required parameter 'credentials' is set
if (credentials == null)
ThrowMissingParameter("AuthLogin", nameof(credentials));

var localVarPath = "/entity/auth/login";

// make the HTTP request
IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
Method.POST, ComposeEmptyQueryParams(), ComposeBody(credentials), ComposeAcceptHeaders(HeaderContentType.None), ComposeEmptyFormParams(), ComposeEmptyFileParams(),
ComposeEmptyPathParams(), ComposeContentHeaders(HeaderContentType.Json | HeaderContentType.Xml | HeaderContentType.WwwForm));

VerifyResponse(localVarResponse, "AuthLogin");

return GetResponseHeaders(localVarResponse);
}

/// <summary>
/// Logs out from the system.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <returns>ApiResponse of Object(void)</returns>
protected ApiResponse<Object> AuthLogoutWithHttpInfo()
{
var localVarPath = "/entity/auth/logout";

// make the HTTP request
IRestResponse localVarResponse = (IRestResponse)this.Configuration.ApiClient.CallApi(localVarPath,
Method.POST, ComposeEmptyQueryParams(), null, ComposeAcceptHeaders(HeaderContentType.None), ComposeEmptyFormParams(), ComposeEmptyFileParams(),
ComposeEmptyPathParams(), ComposeContentHeaders(HeaderContentType.None));

VerifyResponse(localVarResponse, "AuthLogout");

return GetResponseHeaders(localVarResponse);
}

/// <summary>
/// Logs out from the system.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <returns>Task of ApiResponse</returns>
protected async System.Threading.Tasks.Task<ApiResponse<Object>> AuthLogoutAsyncWithHttpInfo()
{
var localVarPath = "/entity/auth/logout";

// make the HTTP request
IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
Method.POST, ComposeEmptyQueryParams(), null, ComposeAcceptHeaders(HeaderContentType.None), ComposeEmptyFormParams(), ComposeEmptyFileParams(),
ComposeEmptyPathParams(), ComposeContentHeaders(HeaderContentType.None));

VerifyResponse(localVarResponse, "AuthLogout");

return GetResponseHeaders(localVarResponse);
}
#endregion
}
}
File renamed without changes.
105 changes: 105 additions & 0 deletions Acumatica.RESTClient/AcumaticaApi/RootApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using RestSharp;
using Acumatica.RESTClient.Client;
using Acumatica.Auth.Model;
using Acumatica.RESTClient.Api;

namespace Acumatica.Auth.Api
{

/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class RootApi : BaseApi
{
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="RootApi"/> class.
/// </summary>
/// <returns></returns>
public RootApi(String basePath) : base(basePath)
{ }

/// <summary>
/// Initializes a new instance of the <see cref="RootApi"/> class
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <returns></returns>
public RootApi(Configuration configuration) : base(configuration)
{ }
#endregion

#region Public Methods

/// <summary>
/// Returns the version of the Acumatica ERP instance and the endpoints available in this instance.
/// Available stating from 2019 R2 version of Acumatica ERP.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <returns>VersionAndEndpoints</returns>
public VersionAndEndpoints RootGet()
{
ApiResponse<VersionAndEndpoints> localVarResponse = RootGetWithHttpInfo();
return localVarResponse.Data;
}
/// <summary>
/// Returns the version of the Acumatica ERP instance and the endpoints available in this instance.
/// Available stating from 2019 R2 version of Acumatica ERP.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <returns>Task of VersionAndEndpoints</returns>
public async System.Threading.Tasks.Task<VersionAndEndpoints> RootGetAsync()
{
ApiResponse<VersionAndEndpoints> localVarResponse = await RootGetAsyncWithHttpInfo();
return localVarResponse.Data;

}
#endregion

#region Implementation
/// <summary>
/// Returns the version of the Acumatica ERP instance and the endpoints available in this instance.
/// Available stating from 2019 R2 version of Acumatica ERP.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <returns>ApiResponse of VersionAndEndpoints</returns>
protected ApiResponse<VersionAndEndpoints> RootGetWithHttpInfo()
{
var localVarPath = "/entity";

// make the HTTP request
IRestResponse localVarResponse = (IRestResponse)this.Configuration.ApiClient.CallApi(localVarPath,
Method.GET, ComposeEmptyQueryParams(), null, ComposeAcceptHeaders(HeaderContentType.Xml | HeaderContentType.Json), ComposeEmptyFormParams(), ComposeEmptyFileParams(),
ComposeEmptyPathParams(), ComposeContentHeaders(HeaderContentType.None));

VerifyResponse(localVarResponse, "RootGet");

return DeserializeResponse<VersionAndEndpoints>(localVarResponse);
}

/// <summary>
/// Returns the version of the Acumatica ERP instance and the endpoints available in this instance.
/// Available stating from 2019 R2 version of Acumatica ERP.
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <returns>Task of ApiResponse (VersionAndEndpoints)</returns>
protected async System.Threading.Tasks.Task<ApiResponse<VersionAndEndpoints>> RootGetAsyncWithHttpInfo()
{
var localVarPath = "/entity";

// make the HTTP request
IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
Method.GET, ComposeEmptyQueryParams(), null, ComposeAcceptHeaders(HeaderContentType.Json | HeaderContentType.Xml), ComposeEmptyFormParams(), ComposeEmptyFileParams(),
ComposeEmptyPathParams(), ComposeContentHeaders(HeaderContentType.None));

VerifyResponse(localVarResponse, "RootGet");

return DeserializeResponse<VersionAndEndpoints>(localVarResponse);
}
#endregion
}
}
Loading

0 comments on commit 9160423

Please sign in to comment.