fmsouza / nubank-api

A high level API to connect to Nubank service and download your purchase records.
GNU General Public License v3.0
116 stars 19 forks source link

Ajustando métodos getBalance e getFeed #8

Closed matheuscouto closed 2 years ago

matheuscouto commented 3 years ago

Percebi que os métodos getBalance e getFeed estão utilizando a estrutura errada de retorno do graphQL e sempre retornam undefined por isso. Para consertar fiz as alterações abaixo:

getBalance de:

  public async getBalance(): Promise<number> {
    const data = await this._context.http.graphql(
      GqlOperations.QUERY_ACCOUNT_BALANCE
    );
    return data.viewer?.savingsAccount?.currentSavingsBalance?.netAmount;
  }

para:

  public async getBalance(): Promise<number> {
    const { data } = await this._context.http.graphql(
      GqlOperations.QUERY_ACCOUNT_BALANCE
    );
    return data.viewer?.savingsAccount?.currentSavingsBalance?.netAmount;
  }

getFeed de:

  public async getFeed(): Promise<AccountTransaction[]> {
    const data = await this._context.http.graphql(
      GqlOperations.QUERY_ACCOUNT_FEED
    );
    return data?.viewer?.savingsAccount?.feed;
  }

para:

  public async getFeed(): Promise<AccountTransaction[]> {
    const { data } = await this._context.http.graphql(
      GqlOperations.QUERY_ACCOUNT_FEED
    );
    return data?.viewer?.savingsAccount?.feed;
  }