redd icon indicating copy to clipboard operation
redd copied to clipboard

flair_listing: cannot unmarshal

Open EliteMasterEric opened this issue 5 years ago • 0 comments

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 avatar Feb 27 '19 22:02 EliteMasterEric