wealthica / vezgo-sdk-js

MIT License
29 stars 5 forks source link

Issue with sync method #37

Closed bohdan-tkachuk closed 3 months ago

bohdan-tkachuk commented 1 year ago

Version ^1.0.2. I always get 400 error when I query account sync method. If I execute the same request via postman (or axios) it works fine.

codynguyen commented 1 year ago

@bohdan-tkachuk could you send the code you used, from initializing the sdk, up to the accounts.sync() call?

bohdan-tkachuk commented 1 year ago

Here is how I initialize sdk and login:

const vezgoSdk = VezgoSDK.init(config.credentials);
this.client = new VezgoClient(await vezgoSdk.login('user_' + userId));

And how I use sync method:

try {
   return await this.client.accounts.sync(accountId);
} catch (e) {
   Logger.error(e.message, 'VezgoClient');
}

All other methods works for me, except this one..

codynguyen commented 1 year ago

@bohdan-tkachuk could you try something like this?


// Create a Vezgo SDK instance
const vezgo = Vezgo.init({
  clientId: 'YOUR_CLIENT_ID',
  secret: 'YOUR_CLIENT_SECRET',
});

// Log user(s) in
const user = vezgo.login('USER_ID');

// Call user APIs
const account = await user.accounts.sync('ACCOUNT_ID');
bohdan-tkachuk commented 1 year ago

@codynguyen tried sync method

// Create a Vezgo SDK instance
const vezgo = VezgoSDK.init({
  clientId: this.config.credentials.clientId,
  secret: this.config.credentials.secret,
});

const user = await vezgo.login('USER_ID');

return await user.accounts.sync('ACCOUNT_ID');

And got Request failed with status code 400 error

Then tried getOne method

// Create a Vezgo SDK instance
const vezgo = VezgoSDK.init({
  clientId: this.config.credentials.clientId,
  secret: this.config.credentials.secret,
});

const user = await vezgo.login('USER_ID');

return await user.accounts.getOne('ACCOUNT_ID');

It worked for me. And the same with my current implementation, I'm able to query all method with only ONE exception - sync method.