Nikey646 / VndbSharp

A C# Vndb API Library. #OriginalNamingScheme
MIT License
18 stars 4 forks source link

[Feature Request]Add support for the latest user list API features #39

Closed micah686 closed 6 years ago

micah686 commented 7 years ago

Yorhel added some new features to the API: 2017-08-14

Add 'uid' field to "get votelist/vnlist/wishlist" commands
Add 'vn' filter to the same commands
The 'uid' filter for these commands is now optional, making it possible to find all list entries for a particular VN
Nikey646 commented 7 years ago

The Update/2017-08-14 branch should add all 3 new features... Well 2 new features, since the current branch technically already supports everything except for the uid on the models, while the vn filter (Which could be implemented by the user via implementing the IFilter interface, or extending the Abstractfilter class) but has been added to the core library anyways.

Lemme know if it works so i can merge it into master.

micah686 commented 7 years ago

So, using this code:

using (Vndb client= new Vndb(Username, Password))
{
  var data = await client.GetVoteListAsync(VndbFilters.UserId.Equals(_userId) | VndbFilters.VisualNovelId.Equals(4));
  if (data == null)
  {
     HandleError.HandleErrors(client.GetLastError());
  }
}

I keep getting:

Get Response | error {"field":"vid","value":4,"msg":"Unknown field 'vid'","op":"=","id":"filter"}
{"field":"vid","value":4,"msg":"Unknown field 'vid'","op":"=","id":"filter"}
A InvalidFilter Error occured, the filter combination of "vid", "=", "4" is not a valid combination.
Message: Unknown field 'vid'
Nikey646 commented 7 years ago

You want to use & (and), not | (or). You can also alternatively use the IFilter And(IFilter, IFilter) extension method. You shouldn't be disposing the Vndb instance until you no longer need it at all.

And i'm not entirely sure whats wrong there, the recent changes to the documentation have been fairly inconsistent, the filter name listed under 5.7 is vid while it's listed as vn under the change log... :s

micah686 commented 7 years ago

Even when using the right filters: var data = await client.GetVoteListAsync( VndbFilters.UserId.Equals(_userId)& VndbFilters.VisualNovelId.Equals(4)); I still get

Get Response | error {"field":"vid","op":"=","msg":"Unknown field 'vid'","value":4,"id":"filter"}
{"field":"vid","op":"=","msg":"Unknown field 'vid'","value":4,"id":"filter"}
Nikey646 commented 7 years ago

Same error, it's not any different for some reason it doesn't understand the vid filter. I'll fiddle with it when i'm no longer busy unless you want to do it.

micah686 commented 7 years ago

It seems like due to a "possible(?)" mistake in the API, the 'vid' filter is really 'vn'. Try it replacing protected override String FilterName { get; } = "vid"; with protected override String FilterName { get; } = "vn";.

I asked this question on the forums, so it would probably be best not to make changes regarding this behavior until we get a proper response.

micah686 commented 7 years ago

Fixed with #40. This also fixes the last issue I had with the Update/2017-08-14 branch, so go ahead and merge it into master once you accept the pull request.