File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
WooCommerce/Classes/Yosemite Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,17 @@ class StoresManager {
4949
5050 /// Switches the internal state to Authenticated.
5151 ///
52- func authenticate( credentials: Credentials , onCompletion : ( ( Error ? ) -> Void ) ? = nil ) {
52+ func authenticate( credentials: Credentials ) -> StoresManager {
5353 state = AuthenticatedState ( credentials: credentials)
5454 sessionManager. defaultCredentials = credentials
5555
56+ return self
57+ }
58+
59+ /// Synchronizes all of the Session's Entities.
60+ ///
61+ func synchronizeEntities( onCompletion: ( ( Error ? ) -> Void ) ? = nil ) {
62+ synchronizeAccount ( onCompletion: onCompletion)
5663 }
5764
5865 /// Switches the state to a Deauthenticated one.
@@ -91,6 +98,19 @@ private extension StoresManager {
9198
9299 dispatch ( action)
93100 }
101+
102+ /// Synchronizes the WordPress.com Account, associated with the current credentials.
103+ ///
104+ func synchronizeAccount( onCompletion: ( ( Error ? ) -> Void ) ? ) {
105+ let action = AccountAction . synchronizeAccount { [ weak self] ( account, error) in
106+ if let `self` = self , let account = account, self . isAuthenticated {
107+ self . sessionManager. defaultAccount = account
108+ }
109+
110+ onCompletion ? ( error)
111+ }
112+
113+ dispatch ( action)
94114 }
95115}
96116
You can’t perform that action at this time.
0 commit comments