Example #1
0
        public static async Task <ScopedList <TResult> > GetList <TResult>(
            this IListable <TResult> resource,
            int?offset     = null,
            int?limit      = null,
            DateTime?from  = null,
            DateTime?to    = null,
            Ordering?order = null
            ) where TResult : ModelBase
        {
            var opts = new ListOptions
            {
                Offset = offset,
                Limit  = limit,
                From   = from,
                To     = to,
                Order  = order
            };

            var path = resource.BasePath;

            if (!opts.IsEmpty())
            {
                var content = serializer.ExtractFormValues(opts);
                path += $"?{await content.ReadAsStringAsync().ConfigureAwait(false)}";
            }

            // TODO: Actual list container type that can be re-requested and supports paging as well.
            return(await resource.Requester.Request <ScopedList <TResult> >(
                       resource.Endpoint,
                       "GET",
                       path
                       ).ConfigureAwait(false));
        }