avinashbot / redd

Redd is a batteries-included API wrapper for reddit.
MIT License
186 stars 75 forks source link

flair_listing: cannot unmarshal #93

Closed EliteMasterEric closed 1 year ago

EliteMasterEric commented 5 years ago

I am running the following code:

session.subreddit("StevenUniverseTest").get_flair(session.user("EliteMasterEric"))

And getting this error:

unmarshaller.rb:31:in `unmarshal': cannot unmarshal: {:flair_css_class=>"", :user=>"EliteMasterEric", :flair_text=>":lapisuplifting: test"} (RuntimeError)

The issue is caused by the fact that Listing assumes that all Listings sent by the Reddit API are comprised of Models, which is not the case for many of them, but happens to be the case for all Listings implemented by Redd except for Subreddit.flair_listing, which is currently not functional. The solution is to remove this assumption from Listing, then convert all other uses to a new class, ModelListing, which marshals all Listing elements as with current behavior.

I will be making a pull request implementing this change soon.

EliteMasterEric commented 1 year ago

Pretty sure this repo is unmaintained.