BoxCollaboration model missing available fields in AccessibleBy
trevordebard opened this issue · comments
- I have checked that the [SDK documentation][sdk-docs] doesn't solve my issue.
- I have checked that the [API documentation][api-docs] doesn't solve my issue.
- I have searched the [Box Developer Forums][dev-forums] and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
- I have searched [Issues in this repo][github-repo] and my issue isn't already reported.
Description of the Issue
When viewing a collaboration, the AccessibleBy
attribute does not contain "name" or "login" even though these are returned in the API response.
var collabs = await client.CollaborationsManager. GetCollaborationAsync("123")
foreach(var c an collabs.Entries)
{
Console.WriteLine(c.AccessibleBy.Name); // Name should be available here but is not
}
Change Requested
Update the BoxCollaboration data model to include Name and Login as AccessibleBy fields.
Hi @trevordebard,
Collaboration can be a BoxUser
or a BoxGroup
, and for this reason, the AccessibleBy
field of the BoxCollaboration
object is of type BoxEntity
, so as not to violate this constraint.
To access the value of this field, we can check its current type and cast the object accordingly, for example using pattern matching as shown in the following example:
var collabs = await userClient.CollaborationsManager.GetCollaborationAsync("123");
if (collabs.AccessibleBy is BoxUser user)
{
Console.WriteLine("userID:{0}, name:{1}, login:{2}", user.Id, user.Name, user.Login);
}
else if (collabs.AccessibleBy is BoxGroup group)
{
Console.WriteLine("groupID:{0}, groupName: {1}", group.Id, group.Name);
}
Does this solve your problem?
Thank you @arjankowski! It makes sense why it was set up that way now, and this resolves my issue. Thank you!