dropbox/dropbox-sdk-obj-c

DBCOMMONRootInfo does not contain 'home_path' property which is described in the documentation

apodrugin opened this issue · 4 comments

According to the documentation (https://www.dropbox.com/developers/reference/namespace-guide) 'root_info' dictionary contains 'home_path' property. This property is present in JSON response, but it is not parsed and is missed in the DBCOMMONRootInfo interface.

The homePath field is only set on DBCOMMONTeamRootInfo, not DBCOMMONUserRootInfo or DBCOMMONRootInfo itself.

DBCOMMONTeamRootInfo and DBCOMMONUserRootInfo both inherit from DBCOMMONRootInfo, and correspond to the "team" and "user" tags shown in the Namespace Guide, respectively.

You'll only get a DBCOMMONTeamRootInfo if the user is on a team using a "team space". Otherwise, there isn't a home_path.

Which type are you getting? If you are somehow getting a DBCOMMONTeamRootInfo in particular without a homePath, please share the output here so we can investigate. Thanks!

Thank you for your response! I have missed that DBCOMMONRootInfo has subclasses, because DBUSERSFullAccount exposes 'rootInfo' property with DBCOMMONRootInfo return type and it is not mentioned in documentation in code that it may return instances of the subclasses with additional information. So, the right way to get home_path is to check that 'rootInfo' is actually DBCOMMONTeamRootInfo class and cast to it? Am I right?

That's correct, you'd need to check and cast the type in order to access that type-specific homePath property. That would look something like this:

[[client.usersRoutes getCurrentAccount] setResponseBlock:^(DBUSERSFullAccount *account, DBNilObject *_, DBRequestError *error) {
    if (account) {
        
        if ([account.rootInfo isKindOfClass:[DBCOMMONTeamRootInfo class]]) {
            DBCOMMONTeamRootInfo *teamRootInfo = (DBCOMMONTeamRootInfo *)account.rootInfo;
            NSLog(@"%@", teamRootInfo);
            NSLog(@"%@", teamRootInfo.homePath);
        } else if ([account.rootInfo isKindOfClass:[DBCOMMONUserRootInfo class]]) {
            DBCOMMONUserRootInfo *userRootInfo = (DBCOMMONUserRootInfo *)account.rootInfo;
            NSLog(@"%@", userRootInfo);
        }
        
    } else if (error) {
        NSLog(@"%@", error);
    }
}];

Please let me know if that works as expected for you. Thanks!

I have checked it in my environment. Everything works as expected. Thank you!