forked from Acumatica/AcumaticaRESTAPIClientForCSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare the project for publishing as NugetPackage
- Loading branch information
dnaumov
committed
Sep 23, 2021
1 parent
ccfcf67
commit 9160423
Showing
19 changed files
with
1,200 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.