/// <summary> /// Prepare and populate the REST-resource string that should be send /// </summary> /// <param name="type"></param> /// <param name="status">Filters the vouchers by their status. Bit flags can be used here. Warning: Status "Overdue" can not be used together with other status.</param> /// <param name="archived"></param> /// <param name="page"></param> /// <param name="pageSize"></param> /// <returns></returns> private string PrepareVoucherListString(VoucherType type, VoucherStatus status, VoucherListArchived archived, int page, int pageSize) { string resource = "/voucherlist?"; // Parse Type string vouchertype = "voucherType="; foreach (VoucherType e in Enum.GetValues(typeof(VoucherType))) { if (type.HasFlag(e)) { vouchertype += e.ToString().ToLower() + ","; } } vouchertype = vouchertype.Substring(0, vouchertype.Length - 1); // Parse Status string voucherstatus = "voucherStatus="; foreach (VoucherStatus e in Enum.GetValues(typeof(VoucherStatus))) { if (status.HasFlag(e)) { voucherstatus += e.ToString().ToLower() + ","; } } // TODO: Status "Overdue" cannot be filtered with other status filters voucherstatus = voucherstatus.Substring(0, voucherstatus.Length - 1); // Parse Archived string strArchived = ""; if (archived != VoucherListArchived.Both) { switch (archived) { case VoucherListArchived.Archived: strArchived = "archived=true"; break; case VoucherListArchived.NonArchived: strArchived = "archived=false"; break; } } // Parse PageSize string strPageSize = ""; if (pageSize != 25) { if (pageSize > 250) { pageSize = 250; } if (pageSize < 1) { pageSize = 1; } strPageSize = $"size={pageSize}"; } // Parse Page string strPage = ""; if (page > 0) { strPage = $"page={page}"; } string result = $"{resource}{vouchertype}&{voucherstatus}&{strArchived}&{strPageSize}&{strPage}"; return(result); }