Skip to content

Latest commit

 

History

History
86 lines (72 loc) · 2.07 KB

README.md

File metadata and controls

86 lines (72 loc) · 2.07 KB

Fetching Products Examples

Here you will find a collection of CLI commands that take a link_id, fetch transactions and store them in a postgres database with the following table schemas:

CREATE TABLE links (
    id SERIAL NOT NULL,
    moneykit_id VARCHAR NOT NULL,
    transaction_sync_cursor VARCHAR,
    PRIMARY KEY (id),
    UNIQUE (moneykit_id)
);

CREATE TABLE transactions (
    id SERIAL NOT NULL,
    link_id INTEGER NOT NULL,
    moneykit_id VARCHAR NOT NULL,
    timestamp TIMESTAMP WITHOUT TIME ZONE NOT NULL,
    description VARCHAR,
    pending BOOLEAN NOT NULL,
    PRIMARY KEY (id),
    FOREIGN KEY(link_id) REFERENCES links (id),
    UNIQUE (moneykit_id)
);

We have left the accounts model out of this example for simplicity. In reality the relationships should be set up as:

  • links
  • accounts
    • link_id: Foreign key to links.id
  • transactions
    • account_id: Foreign key to accounts.id

Getting started

Choose the language for your CLI:

  • python: Uses MoneyKit's Python SDK

You must have an already connected link_id to be able to use this CLI too. Use our create_link example to create one if you don't already have a link_id.

Set your environment variables

Copy .env.sample to fetching_products/.env.

Set your MONEYKIT_CLIENT_ID and MONEYKIT_CLIENT_SECRET in the .env file. We recommend you use your sandbox keys to play around with test institutions.

Run CLI

  1. Start docker and postgres
    make python
  2. Create postgres database tables
    ./cli create-db
  3. Fetch initial transactions
    ./cli apply-diff <link_id>
  4. Print cached transactions from database
    ./cli show <link_id>
  5. Refresh transactions
    ./cli refresh <link_id>
  6. Check refresh state until done
    ./cli state <link_id>
  7. Apply new transaction diff
    ./cli apply-diff <link_id>
  8. Print latest cached transactions from database
    ./cli show <link_id>