forked from Adyen/adyen-dotnet-api-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccountsService.cs
128 lines (112 loc) · 7.29 KB
/
AccountsService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* Account API
*
*
* The version of the OpenAPI document: 6
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Adyen.Model;
using Adyen.Model.PlatformsAccount;
namespace Adyen.Service.PlatformsAccount
{
/// <summary>
/// AccountsService Interface
/// </summary>
public interface IAccountsService
{
/// <summary>
/// Close an account
/// </summary>
/// <param name="closeAccountRequest"><see cref="CloseAccountRequest"/> - </param>
/// <param name="requestOptions"><see cref="RequestOptions"/> - Additional request options.</param>
/// <returns><see cref="CloseAccountResponse"/>.</returns>
Model.PlatformsAccount.CloseAccountResponse CloseAccount(CloseAccountRequest closeAccountRequest = default, RequestOptions requestOptions = default);
/// <summary>
/// Close an account
/// </summary>
/// <param name="closeAccountRequest"><see cref="CloseAccountRequest"/> - </param>
/// <param name="requestOptions"><see cref="RequestOptions"/> - Additional request options.</param>
/// <param name="cancellationToken"> A CancellationToken enables cooperative cancellation between threads, thread pool work items, or Task objects.</param>
/// <returns>Task of <see cref="CloseAccountResponse"/>.</returns>
Task<Model.PlatformsAccount.CloseAccountResponse> CloseAccountAsync(CloseAccountRequest closeAccountRequest = default, RequestOptions requestOptions = default, CancellationToken cancellationToken = default);
/// <summary>
/// Create an account
/// </summary>
/// <param name="createAccountRequest"><see cref="CreateAccountRequest"/> - </param>
/// <param name="requestOptions"><see cref="RequestOptions"/> - Additional request options.</param>
/// <returns><see cref="CreateAccountResponse"/>.</returns>
Model.PlatformsAccount.CreateAccountResponse CreateAccount(CreateAccountRequest createAccountRequest = default, RequestOptions requestOptions = default);
/// <summary>
/// Create an account
/// </summary>
/// <param name="createAccountRequest"><see cref="CreateAccountRequest"/> - </param>
/// <param name="requestOptions"><see cref="RequestOptions"/> - Additional request options.</param>
/// <param name="cancellationToken"> A CancellationToken enables cooperative cancellation between threads, thread pool work items, or Task objects.</param>
/// <returns>Task of <see cref="CreateAccountResponse"/>.</returns>
Task<Model.PlatformsAccount.CreateAccountResponse> CreateAccountAsync(CreateAccountRequest createAccountRequest = default, RequestOptions requestOptions = default, CancellationToken cancellationToken = default);
/// <summary>
/// Update an account
/// </summary>
/// <param name="updateAccountRequest"><see cref="UpdateAccountRequest"/> - </param>
/// <param name="requestOptions"><see cref="RequestOptions"/> - Additional request options.</param>
/// <returns><see cref="UpdateAccountResponse"/>.</returns>
Model.PlatformsAccount.UpdateAccountResponse UpdateAccount(UpdateAccountRequest updateAccountRequest = default, RequestOptions requestOptions = default);
/// <summary>
/// Update an account
/// </summary>
/// <param name="updateAccountRequest"><see cref="UpdateAccountRequest"/> - </param>
/// <param name="requestOptions"><see cref="RequestOptions"/> - Additional request options.</param>
/// <param name="cancellationToken"> A CancellationToken enables cooperative cancellation between threads, thread pool work items, or Task objects.</param>
/// <returns>Task of <see cref="UpdateAccountResponse"/>.</returns>
Task<Model.PlatformsAccount.UpdateAccountResponse> UpdateAccountAsync(UpdateAccountRequest updateAccountRequest = default, RequestOptions requestOptions = default, CancellationToken cancellationToken = default);
}
/// <summary>
/// Represents a collection of functions to interact with the AccountsService API endpoints
/// </summary>
public class AccountsService : AbstractService, IAccountsService
{
private readonly string _baseUrl;
public AccountsService(Client client) : base(client)
{
_baseUrl = CreateBaseUrl("https://cal-test.adyen.com/cal/services/Account/v6");
}
public Model.PlatformsAccount.CloseAccountResponse CloseAccount(CloseAccountRequest closeAccountRequest = default, RequestOptions requestOptions = default)
{
return CloseAccountAsync(closeAccountRequest, requestOptions).ConfigureAwait(false).GetAwaiter().GetResult();
}
public async Task<Model.PlatformsAccount.CloseAccountResponse> CloseAccountAsync(CloseAccountRequest closeAccountRequest = default, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
var endpoint = _baseUrl + "/closeAccount";
var resource = new ServiceResource(this, endpoint);
return await resource.RequestAsync<Model.PlatformsAccount.CloseAccountResponse>(closeAccountRequest.ToJson(), requestOptions, new HttpMethod("POST"), cancellationToken).ConfigureAwait(false);
}
public Model.PlatformsAccount.CreateAccountResponse CreateAccount(CreateAccountRequest createAccountRequest = default, RequestOptions requestOptions = default)
{
return CreateAccountAsync(createAccountRequest, requestOptions).ConfigureAwait(false).GetAwaiter().GetResult();
}
public async Task<Model.PlatformsAccount.CreateAccountResponse> CreateAccountAsync(CreateAccountRequest createAccountRequest = default, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
var endpoint = _baseUrl + "/createAccount";
var resource = new ServiceResource(this, endpoint);
return await resource.RequestAsync<Model.PlatformsAccount.CreateAccountResponse>(createAccountRequest.ToJson(), requestOptions, new HttpMethod("POST"), cancellationToken).ConfigureAwait(false);
}
public Model.PlatformsAccount.UpdateAccountResponse UpdateAccount(UpdateAccountRequest updateAccountRequest = default, RequestOptions requestOptions = default)
{
return UpdateAccountAsync(updateAccountRequest, requestOptions).ConfigureAwait(false).GetAwaiter().GetResult();
}
public async Task<Model.PlatformsAccount.UpdateAccountResponse> UpdateAccountAsync(UpdateAccountRequest updateAccountRequest = default, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
var endpoint = _baseUrl + "/updateAccount";
var resource = new ServiceResource(this, endpoint);
return await resource.RequestAsync<Model.PlatformsAccount.UpdateAccountResponse>(updateAccountRequest.ToJson(), requestOptions, new HttpMethod("POST"), cancellationToken).ConfigureAwait(false);
}
}
}