-
Notifications
You must be signed in to change notification settings - Fork 21
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
[API PULL] Backbone for SYNC endpoint #2788
base: feature/api-pull-sync-endpoint
Are you sure you want to change the base?
[API PULL] Backbone for SYNC endpoint #2788
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/api-pull-sync-endpoint #2788 +/- ##
===================================================================
+ Coverage 66.7% 67.1% +0.4%
- Complexity 0 4684 +4684
===================================================================
Files 316 481 +165
Lines 4921 19625 +14704
Branches 1204 0 -1204
===================================================================
+ Hits 3282 13174 +9892
- Misses 1502 6451 +4949
+ Partials 137 0 -137
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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 changes, they are working as expected and I'm getting the response either from the defaults or the option.
I just left a couple comments, let me know if you think that would be worthwhile to do.
[ | ||
'methods' => TransportMethods::READABLE, | ||
'callback' => $this->get_sync_callback(), | ||
'permission_callback' => $this->get_permission_callback(), |
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.
Considering that we only want these endpoints accessible by the API Pull implementation. In the WC endpoints we check for the gla_syncable
parameter being set to 1 in the request before we modify the responses.
Should we have a custom permissions callback to also check if this is set? Not very difficult to get around, but it might provide better separation.
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 I will update that in future PRs if that's ok
Co-authored-by: Mik <[email protected]>
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 changes. I retested and it's return a hybrid of the option and defaults. So everything is as expected:
{
"products": {
"push": true,
"pull": true
},
"coupons": {
"push": false,
"pull": false
},
"shipping": {
"push": true,
"pull": true
},
"settings": {
"pull": false,
"push": false
}
}
Changes proposed in this Pull Request:
This is a preparatory PR for the work related to creating a WPCOM Proxied endpoint allowing to GET and UPDATE the enabled Sync mode.
In this PR we create a backbone for the endpoint getting a default value or the value saved in
wp_options.gla_api_pull_sync_mode
PT: pcTzPl-2yG-p2
Screenshots:
Detailed test instructions:
GET wp-json/wc/gla/sync
wp_options.gla_api_pull_sync_mode
and save some data for example this with all true:a:4:{s:8:"products";a:2:{s:4:"push";b:1;s:4:"pull";b:1;}s:7:"coupons";a:2:{s:4:"push";b:1;s:4:"pull";b:1;}s:8:"shipping";a:2:{s:4:"push";b:1;s:4:"pull";b:1;}s:8:"settings";a:2:{s:4:"push";b:1;s:4:"pull";b:1;}}
Additional details:
Changelog entry