Skip to content

Commit

Permalink
Merge pull request #100 from egg-mode-rs/relationship-wrapper
Browse files Browse the repository at this point in the history
properly deserialize Relationship in user::relation
  • Loading branch information
QuietMisdreavus committed Jul 10, 2020
2 parents cad008b + 5b600f1 commit 2d5614a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/user/fun.rs
Expand Up @@ -127,7 +127,14 @@ where

let req = get(links::users::FRIENDSHIP_SHOW, token, Some(&params));

request_with_json_response(req).await
// the relationship returned by Twitter is actually contained within a `"relationship"` field,
// so this wrapper struct makes sure the data is loaded correctly
#[derive(Deserialize)]
struct RelationWrapper { relationship: Relationship }

let resp: Response<RelationWrapper> = request_with_json_response(req).await?;

Ok(Response::map(resp, |r| r.relationship))
}

/// Lookup the relations between the authenticated user and the given accounts.
Expand Down

0 comments on commit 2d5614a

Please sign in to comment.