-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[spaceship] Add visible_apps relationship to invite users with app permissions and fetch user's app permissions #19053
[spaceship] Add visible_apps relationship to invite users with app permissions and fetch user's app permissions #19053
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! I wanted to point how ESSENTIAL_INCLUDES
convention is supposed to work🙂 otherwise this looks great change 😍
ESSENTIAL_INCLUDES = [ | ||
"visibleApps" | ||
].join(",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't automatically used at all. You need to pass this to the parent API calls.
For example, you need to pass it to the corresponding methods as the default value of includes
argument. This way App Store Connect API will include "visibleApps" objects within the response and spaceship client will automatically map it to visible_apps
property. That's what ESSENTIAL_INCLUDES
convention is supposed to work.
def self.all(filter: {}, includes: Spaceship::ConnectAPI::User::ESSENTIAL_INCLUDES, limit: nil, sort: nil)
- https://github.com/fastlane/fastlane/pull/19053/files#diff-75baf27580ebd9af6509c2bbdb9fca7cd67b716bf144964ffc8e208c397d57bcR49
- https://github.com/fastlane/fastlane/pull/19053/files#diff-75baf27580ebd9af6509c2bbdb9fca7cd67b716bf144964ffc8e208c397d57bcR55
fastlane/spaceship/lib/spaceship/connect_api/models/user.rb
Lines 41 to 45 in c0b94f1
def self.all(client: nil, filter: {}, includes: nil, limit: nil, sort: nil) client ||= Spaceship::ConnectAPI resps = client.get_users(filter: filter, includes: includes).all_pages return resps.flat_map(&:to_models) end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise visible_apps
property ends up returning nil
depending on how you get the User
object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanatory comment @ainame.
I compared how ESSENTIAL_INCLUDES
are used in App
, AppStoreVersion
models and I thought for a while if user visible_apps
should be fetched by default and I wasn't sure if I should use them as default inlcudes
argument.
I added the definition though to allow to use it as in example testing steps
, e.g.
users = Spaceship::ConnectAPI::User.all(includes: Spaceship::ConnectAPI::User::ESSENTIAL_INCLUDES)
Otherwise those that would like to fetch it would have to investigate what value should be used in includes
.
Should visible_apps
be fetched by default in self.find
and self.all
methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is that if it's not "by default", it shouldn't be named "ESSENTIAL". It sounds more like OPTIONAL_INCLUDES
to me.
https://developer.apple.com/documentation/appstoreconnectapi/list_users
Should visible_apps be fetched by default in self.find and self.all methods?
To me, it can be an "essential" info when it comes to handling users for ASC. Any advice to determine if it's essential? @joshdholtz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the advice will be to go with optional, I'll rename it to OPTIONAL_INCLUDES
. Otherwise, I'll add essential as default values for includes parameters in self.all
and self.find
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I missed this conversation completely 😱 Sorry! I had my notifications under control for a while but lost control this past month 😬 But...
I think essential is fine here!
}) | ||
|
||
ESSENTIAL_INCLUDES = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same applies to this. You need to pass this to self.all
and self.find
.
@@ -48,6 +56,12 @@ def self.find(client: nil, email: nil, includes: nil) | |||
client ||= Spaceship::ConnectAPI | |||
return all(client: client, filter: { email: email }, includes: includes) | |||
end | |||
|
|||
def fetch_visible_apps(client: nil, limit: nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshdholtz Any thought on naming this kind of method with get
vs fetch
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ainame This also made me think for a while and compare code in other models and I wasn't sure if the choice is correct. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too honestly. Some uses "get" others do "fetch" 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UGGHHHH... I hate naming 😅 I honestly don't know which it should be but I do want it to be consistent at some point 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed it to get
and it's used more in code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this out and its working good 😊 Thanks for adding this! Really appreciate the contribution ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congratulations! 🎉 This was released as part of fastlane 2.190.0 🚀
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validMotivation and Context
User
andUserInvitation
models should have a relationship tovisible_apps
to manage app permissions.Description
Changes:
It's possible to assign app permissions when inviting user with
post_user_invitation
.It's possible to fetch app permissions (
visible_apps
) for bothUser
andUserInvitation
Testing Steps
Testing in
irb
: