From 32d93d00faf0b476ebf2ae402cfd418684f6b3f9 Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Tue, 28 Jun 2022 12:54:38 +0200 Subject: [PATCH] feat: add custom request parameters --- src/Models/GetOptions.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Models/GetOptions.cs b/src/Models/GetOptions.cs index 4175d74..e93f16d 100644 --- a/src/Models/GetOptions.cs +++ b/src/Models/GetOptions.cs @@ -1,4 +1,5 @@ using Stream.Rest; +using System.Collections.Generic; namespace Stream.Models { @@ -17,6 +18,8 @@ public class GetOptions private string _feed_slug = null; private string _user_id = null; + private IDictionary _custom = null; + public GetOptions WithOffset(int offset) { _offset = offset; @@ -77,6 +80,17 @@ public GetOptions WithUserId(string userId) return this; } + public GetOptions WithCustom(string key, string value) + { + if (_custom == null) + { + _custom = new Dictionary(); + } + + _custom.Add(key, value); + return this; + } + internal void Apply(RestRequest request) { request.AddQueryParameter("offset", _offset.ToString()); @@ -97,6 +111,12 @@ internal void Apply(RestRequest request) if (!string.IsNullOrWhiteSpace(_user_id)) request.AddQueryParameter("user_id", _user_id); + if (_custom != null) + { + foreach (KeyValuePair kvp in _custom) + request.AddQueryParameter(kvp.Key, kvp.Value); + } + _filter?.Apply(request); _marker?.Apply(request); _reaction?.Apply(request);