-
Notifications
You must be signed in to change notification settings - Fork 12
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
Bug 1560713 - Move to Google API v3 #207
Conversation
f15ac8b
to
ebd47bd
Compare
@@ -79,9 +79,17 @@ def commit_transaction(self): | |||
|
|||
self._edit_id = None | |||
|
|||
@transaction_required |
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 comment doesn't block or even relate to this PR, it's a more general mozapkpublisher
musing:
I wonder if, instead of having a mutable EditService
and having checks before operation to assert state (which is what we're doing relatively ergonomically with this @transaction_required
annotation), we could utilize typestates. So, you'll call a function to start the transaction, and you'll receive a transaction object that can perform all the operations (and commit at the end).
This way, it's easier to use this API, since you don't have functions on your objects that have implicit requirements - you physically can't call transaction functions until you've started the transaction. Additionally, there's less room for errors when changing the API, such as forgetting the @transaction_required
annotation, since required resources (like edit_id
) would sit in the transaction object.
I'm tempted to create a future work ticket, but I'm interested in your thoughts :)
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.
That's a great idea! Yeah, we should get rid of this @transaction_required
pattern, we don't even create multiple transactions in the code base. That's a YAGNI I could have avoided.
I've never heard of the typestates pattern. After glancing at it, it seems this pattern can be achieved by a context manager in python https://docs.python.org/3/library/contextlib.html. How does it sound to you?
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 was originally focused on improving our types (splitting the "transaction" into its own type), but leveraging a context manager for commiting the transaction definitely improves ergonomics further, good call 😁
@@ -188,6 +201,6 @@ def connect(service_account, credentials_file_path, api_version='v2'): | |||
http = httplib2.Http() | |||
http = credentials.authorize(http) | |||
|
|||
service = build('androidpublisher', api_version, http=http, cache_discovery=False) | |||
service = build(serviceName='androidpublisher', version='v3', http=http, cache_discovery=False) |
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 hard-coding the api version here, that's 💯
Fixed. It was a bug on the Google Play server.
Please don't review yet, the code is currently buggy. It returns:I contacted the Google Play support.Fixes #67