-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: GetFeed of LogRecord fails in Geotab.Checkmate.ObjectModel package version 5.7.2103.1 #154
Comments
Tried with package version 5.7.2102.1, same issue. Issue also seems to affect all |
Ah, the reason is that I wasn't using var gps = await api.CallAsync<FeedResult<LogRecord>>("GetFeed", typeof(LogRecord), new
{
search = searchParams,
}); That said, your NuGet package is very strange - I don't understand why you are forcing the use of magic strings to invoke methods instead of proper strongly-typed methods, which is the entire point of a strongly-typed language like C#: public interface IApi
{
Task<FeedResult<TEntity>> GetFeedAsync<TEntity>(object parameters = null, CancellationToken cancellationToken);
} Implementation of the above would simply delegate to the current public class API : IApi
{
public async Task<FeedResult<TEntity>> GetFeedAsync<TEntity>(object parameters = null, CancellationToken cancellationToken = default(CancellationToken))
where TEntity : Entity
=> await CallAsync<FeedResult<TEntity>>("GetFeed", typeof(TEntity), parameters, cancellationToken);
} Literally a handful of lines of code that would make the package so much more user-friendly... |
I've created the following classes to make using this package easier: public class ApiGetParameters
{
public object Search { get; set; }
public int ResultsLimit { get; set; } = 50_000;
}
public class ApiGetFeedParameters
{
public object Search { get; set; }
public int ResultsLimit { get; set; } = 50_000;
public string FromVersion { get; set; }
}
public static class IApiExtensions
{
public static async Task<IEnumerable<TEntity>> GetAsync<TEntity>(this IApi api,
ApiGetParameters parameters = null, CancellationToken cancellationToken = default)
where TEntity : Entity
=> await api.CallAsync<IEnumerable<TEntity>>("Get", typeof(TEntity), new
{
search = parameters?.Search,
resultsLimit = parameters?.ResultsLimit,
}, cancellationToken);
public static async Task<FeedResult<TEntity>> GetFeedAsync<TEntity>(this IApi api,
ApiGetFeedParameters parameters = null, CancellationToken cancellationToken = default)
where TEntity : Entity
=> await api.CallAsync<FeedResult<TEntity>>("GetFeed", typeof(TEntity), new
{
search = parameters?.Search,
resultsLimit = parameters?.ResultsLimit,
fromVersion = parameters?.FromVersion,
}, cancellationToken);
} |
The following NuGet package call:
yields the following request:
which results (via Fiddler) in the following response:
but using the NuGet package, the following exception is raised:
This essentially makes the package unusable for us at this time.
The text was updated successfully, but these errors were encountered: