()
| 336 | } |
| 337 | |
| 338 | sync () { |
| 339 | return Promise.resolve().then(() => { |
| 340 | let params = { |
| 341 | 'sid': this.PROP.sid, |
| 342 | 'skey': this.PROP.skey, |
| 343 | 'pass_ticket': this.PROP.passTicket, |
| 344 | 'lang': 'zh_CN' |
| 345 | } |
| 346 | let data = { |
| 347 | 'BaseRequest': this.getBaseRequest(), |
| 348 | 'SyncKey': this.PROP.syncKey, |
| 349 | 'rr': ~new Date() |
| 350 | } |
| 351 | return this.request({ |
| 352 | method: 'POST', |
| 353 | url: this.CONF.API_webwxsync, |
| 354 | params: params, |
| 355 | data: data |
| 356 | }).then(res => { |
| 357 | let data = res.data |
| 358 | assert.equal(data.BaseResponse.Ret, 0, res) |
| 359 | |
| 360 | this.updateSyncKey(data) |
| 361 | this.PROP.skey = data.SKey || this.PROP.skey |
| 362 | return data |
| 363 | }) |
| 364 | }).catch(err => { |
| 365 | debug(err) |
| 366 | err.tips = '获取新信息失败' |
| 367 | throw err |
| 368 | }) |
| 369 | } |
| 370 | |
| 371 | updateSyncKey (data) { |
| 372 | if (data.SyncKey) { |
no test coverage detected