|
| 1 | +using System.Collections.Generic; |
| 2 | +using System.Text; |
| 3 | +using Bunq.Sdk.Context; |
| 4 | +using Bunq.Sdk.Http; |
| 5 | +using Bunq.Sdk.Json; |
| 6 | +using Bunq.Sdk.Model.Generated.Endpoint; |
| 7 | + |
| 8 | +namespace Bunq.Sdk.Model.Core |
| 9 | +{ |
| 10 | + public class DeviceServerInternal : DeviceServer |
| 11 | + { |
| 12 | + /// <summary> |
| 13 | + /// Create a new DeviceServer providing the installation token in the header and signing the request with the |
| 14 | + /// private part of the key you used to create the installation. The API Key that you are using will be bound to |
| 15 | + /// the IP address of the DeviceServer which you have created.<br/><br/>Using a Wildcard API Key gives you the |
| 16 | + /// freedom to make API calls even if the IP address has changed after the POST device-server.<br/><br/>Find out |
| 17 | + /// more at this link <a href="https://bunq.com/en/apikey-dynamic-ip" |
| 18 | + /// target="_blank">https://bunq.com/en/apikey-dynamic-ip</a>. |
| 19 | + /// </summary> |
| 20 | + public static BunqResponse<int> Create(ApiContext apiContext, string description, string secret, List<string> permittedIps = null, |
| 21 | + IDictionary<string, string> customHeaders = null) |
| 22 | + { |
| 23 | + if (customHeaders == null) customHeaders = new Dictionary<string, string>(); |
| 24 | + |
| 25 | + var apiClient = new ApiClient(apiContext); |
| 26 | + |
| 27 | + var requestMap = new Dictionary<string, object> |
| 28 | + { |
| 29 | + {FIELD_DESCRIPTION, description}, |
| 30 | + {FIELD_SECRET, secret}, |
| 31 | + {FIELD_PERMITTED_IPS, permittedIps}, |
| 32 | + }; |
| 33 | + |
| 34 | + var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); |
| 35 | + var responseRaw = apiClient.Post(ENDPOINT_URL_CREATE, requestBytes, customHeaders); |
| 36 | + |
| 37 | + return ProcessForId(responseRaw); |
| 38 | + } |
| 39 | + } |
| 40 | +} |
0 commit comments