Skip to content

Latest commit

 

History

History
158 lines (136 loc) · 3.15 KB

File metadata and controls

158 lines (136 loc) · 3.15 KB

Corporate Accounts Helpers

Here are some helpers for the Accounts & Balances APIs from Corporate Banking

Interfaces for frontend usage

import { AccountDetail, AccountType, AccountStatement } from '@finastra/api_corporate-accounts/interfaces';

When the importing the interfaces from a frontend only application, be sure to preprend by /interfaces.

GraphQL setup

configs/graphql-config.service.ts

import { GqlOptionsFactory, GqlModuleOptions } from '@nestjs/graphql';
import { Injectable } from '@nestjs/common';
import { CorporateAccountsModule } from '@finastra/api_corporate-accounts';

@Injectable()
export class GqlConfigService implements GqlOptionsFactory {
  createGqlOptions(): GqlModuleOptions {
    const playgroundDevOptions = {
      settings: {
        'request.credentials': 'include',
      },
    };
    return {
      typePaths: ['./node_modules/@finastra/api_corporate-accounts/**/*.graphql'],
      include: [CorporateAccountsModule],
      playground: process.env.NODE_ENV === 'production' ? false : playgroundDevOptions,
    };
  }
}

app.module.ts

import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { CorporateAccountsModule } from '@finastra/api_corporate-accounts';
import { GqlConfigService } from './configs/graphql-config.service';

@Module({
  imports: [
    CorporateAccountsModule.forRoot({}),
    GraphQLModule.forRootAsync({
      useClass: GqlConfigService,
    }),
  ],
})
export class AppModule {}

Example GQL queries

Get accounts

query {
  accounts(limit: 10, offset: 7, fromDate: "2018-01-03", toDate: "2020-03-05", statementLimit: 1) {
    items {
      id
      number
      type
      currency
      balances {
        availableBalance
      }
      statement {
        items {
          amount
        }
      }
    }
    _meta {
      itemCount
    }
  }
}

Get accounts with details and balance

query {
  accountsBalance(accountType: CURRENT, equivalentCurrency: "EUR", fromDate: "2018-01-03", toDate: "2020-03-05") {
    items {
      id
      type
      currency
      availableBalance
      availableBalanceEquivalent
      equivalentCurrency
      details {
        number
        country
        bankShortName
      }
      statement {
        items {
          amount
        }
      }
    }
    _meta {
      itemCount
    }
  }
}

Get specific account detail

query($accountId: ID!) {
  account(id: $accountId) {
    id
    currency
    cutomerReference
  }
}

Get specific account balances

query($accountId: ID!) {
  accountBalance(id: $accountId) {
    id
    currency
    availableBalance
  }
}

Get specific account statement

query($accountId: ID!) {
  accountStatement(id: $accountId, fromDate: "2018-01-03", toDate: "2020-03-05") {
    items {
      currency
      balance
      amount
      postingDate
      valueDate
      transactionType
    }
    _meta {
      itemCount
    }
  }
}