investec-card-api
v0.2.1
Published
A simple package for interacting with Investec's programmable banking card API
Maintainers
Readme
Investec Card Code API
Connect with the Investec Card API.
About
A basic package to connect to the investec programmable card api. It was created to service the investec-ipb command line application.
Installation
Install the package using npm:
npm i investec-card-apiUsage
Import the connector into your code:
import { InvestecCardApi } from 'investec-card-api';Create a new instance of the InvestecCardApi class:
const cardApi = new InvestecCardApi('<clientId>', '<clientSecret>', '<apiKey>');Fetch a list of cards:
const cards = await cardApi.getCards();Upload an environment to a card:
const cards = await cardApi.uploadEnv(cardKey, env);Uploads the code to a card as the saved card code:
const result = await cardApi.uploadCode(cardKey, code);Examples
Example scripts are available in the examples/ directory. These scripts demonstrate how to use the API for common tasks:
examples/list-cards.ts: List all programmable cards for your account.examples/upload-code.ts: Upload code to a programmable card.examples/toggle-feature.ts: Enable or disable the programmable feature on a card.examples/execute-code.ts: Execute code in a simulated transaction context.
Running the Examples
- Copy the relevant example file from the
examples/directory. - Replace the placeholder values (
your-client-id,your-client-secret,your-api-key, andcardKey) with your actual Investec API credentials and card details. - Run the example using
ts-node(or compile to JavaScript and run withnode):
npx ts-node examples/list-cards.tsOr, for another example:
npx ts-node examples/execute-code.tsNote: You must have your Investec API credentials and the
ts-nodepackage installed to run the TypeScript examples directly.
API Response Shapes
Below are the main response shapes returned by this library. All methods return typed objects matching these interfaces:
CardResponse
{
data: {
cards: Array<{
CardKey: number;
CardNumber: string;
IsProgrammable: boolean;
status: string;
CardTypeCode: string;
AccountNumber: string;
AccountId: string;
}>;
}
}CodeResponse
{
data: {
result: {
codeId: string;
code: string;
createdAt: string;
updatedAt: string;
error: null;
}
}
}EnvResponse
{
data: {
result: {
variables: { [key: string]: string };
createdAt: string;
updatedAt: string;
error: null;
};
};
}CodeToggle
{
data: {
result: {
Enabled: boolean;
}
}
}ExecutionResult
{
data: {
result: {
executionItems: Array<ExecutionItem>;
error: null;
}
}
}ExecuteResult
{
data: {
result: Array<ExecutionItem>;
}
}ReferenceResponse
{
data: {
result: Array<{
Code: string;
Name: string;
}>;
}
}License
This project is licensed under the MIT License - see the LICENSE.md file for details
