|
| 1 | +using System.IO; |
| 2 | +using Bunq.Sdk.Model.Generated.Object; |
| 3 | +using Newtonsoft.Json.Linq; |
| 4 | + |
| 5 | +namespace Bunq.Sdk.Tests |
| 6 | +{ |
| 7 | + public class Config |
| 8 | + { |
| 9 | + private const string FIELD_CONFIG_FILE_PATH = "../../../Resources/config.json"; |
| 10 | + private const string FIELD_USER_ID = "USER_ID"; |
| 11 | + private const string FIELD_API_KEY = "API_KEY"; |
| 12 | + private const string FIELD_PERMITTED_IP = "ipAddress"; |
| 13 | + private const string FIELD_ATTACHMENT_PUBLIC_TEST = "AttachmentPublicTest"; |
| 14 | + private const string FIELD_ATTACHMENT_PATH_IN = "PATH_IN"; |
| 15 | + private const string FIELD_ATTACHMENT_DESCRIPTION = "DESCRIPTION"; |
| 16 | + private const string FIELD_ATTACHMENT_CONTENT_TYPE = "CONTENT_TYPE"; |
| 17 | + private const string FIELD_MONETARY_ACCOUNT_ID = "MA_ID"; |
| 18 | + private const string FIELD_MONETARY_ACCOUNT_ID2 = "MA_ID2"; |
| 19 | + private const string FIELD_COUNTER_PARTY_SELF = "CounterPartySelf"; |
| 20 | + private const string FIELD_COUNTER_PARTY_OTHER = "CounterPartyOther"; |
| 21 | + private const string FIELD_COUNTER_ALIAS = "Alias"; |
| 22 | + private const string FIELD_COUNTER_TYPE = "Type"; |
| 23 | + private const string FIELD_TAB_USAGE_SINGLE = "TabUsageSingleTest"; |
| 24 | + private const string FIELD_CASH_REGISTER_ID = "CASH_REGISTER_ID"; |
| 25 | + |
| 26 | + public static int GetCashRegisterId() |
| 27 | + { |
| 28 | + return GetConfig()[FIELD_TAB_USAGE_SINGLE][FIELD_CASH_REGISTER_ID].ToObject<int>(); |
| 29 | + } |
| 30 | + |
| 31 | + public static Pointer GetCounterAliasOther() |
| 32 | + { |
| 33 | + var alias = GetConfig()[FIELD_COUNTER_PARTY_OTHER][FIELD_COUNTER_ALIAS].ToString(); |
| 34 | + var type = GetConfig()[FIELD_COUNTER_PARTY_OTHER][FIELD_COUNTER_TYPE].ToString(); |
| 35 | + |
| 36 | + return new Pointer(type, alias); |
| 37 | + } |
| 38 | + |
| 39 | + public static Pointer GetCounterAliasSelf() |
| 40 | + { |
| 41 | + var alias = GetConfig()[FIELD_COUNTER_PARTY_SELF][FIELD_COUNTER_ALIAS].ToString(); |
| 42 | + var type = GetConfig()[FIELD_COUNTER_PARTY_SELF][FIELD_COUNTER_TYPE].ToString(); |
| 43 | + |
| 44 | + return new Pointer(type, alias); |
| 45 | + } |
| 46 | + |
| 47 | + public static int GetSecondMonetaryAccountId() |
| 48 | + { |
| 49 | + return GetConfig()[FIELD_MONETARY_ACCOUNT_ID2].ToObject<int>(); |
| 50 | + } |
| 51 | + |
| 52 | + public static int GetMonetarytAccountId() |
| 53 | + { |
| 54 | + return GetConfig()[FIELD_MONETARY_ACCOUNT_ID].ToObject<int>(); |
| 55 | + } |
| 56 | + |
| 57 | + public static string GetAttachmentPathIn() |
| 58 | + { |
| 59 | + return GetConfig()[FIELD_ATTACHMENT_PUBLIC_TEST][FIELD_ATTACHMENT_PATH_IN].ToString(); |
| 60 | + } |
| 61 | + |
| 62 | + public static string GetAttachmentDescrpition() |
| 63 | + { |
| 64 | + return GetConfig()[FIELD_ATTACHMENT_PUBLIC_TEST][FIELD_ATTACHMENT_DESCRIPTION].ToString(); |
| 65 | + } |
| 66 | + |
| 67 | + public static string GetAttachmentContentType() |
| 68 | + { |
| 69 | + return GetConfig()[FIELD_ATTACHMENT_PUBLIC_TEST][FIELD_ATTACHMENT_CONTENT_TYPE].ToString(); |
| 70 | + } |
| 71 | + |
| 72 | + public static string GetPermittedIp() |
| 73 | + { |
| 74 | + return GetConfig()[FIELD_PERMITTED_IP].ToString(); |
| 75 | + } |
| 76 | + public static string GetApiKey() |
| 77 | + { |
| 78 | + return GetConfig()[FIELD_API_KEY].ToString(); |
| 79 | + } |
| 80 | + |
| 81 | + public static int GetUserId() |
| 82 | + { |
| 83 | + return GetConfig()[FIELD_USER_ID].ToObject<int>(); |
| 84 | + } |
| 85 | + |
| 86 | + private static JObject GetConfig() |
| 87 | + { |
| 88 | + var fileContentString = File.ReadAllText(FIELD_CONFIG_FILE_PATH); |
| 89 | + |
| 90 | + return JObject.Parse(fileContentString); |
| 91 | + } |
| 92 | + |
| 93 | + } |
| 94 | +} |
0 commit comments