Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions dist/common/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
export type TellerOptionsBase = {
accessToken: string;
};
/**
* Using the latest Teller Version: 2020-10-12
*/
export type TellerOptionsPagination = TellerOptionsBase & {
cursor: string;
limit: number;
/**
* The maximum number of transactions to return in the API response.
*/
count?: number;
/**
* The transaction from where to start the page.
* The first transaction in the API response will be the one immediately before the transaction in the ledger with this id.
*
* example: txn_oiluj93igokseo0i3a005
*/
from_id?: string;
Comment on lines +8 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comments are nice but there's no need for a renaming of the options here. cursor and limit are just generalized term for count and from_id understood by everyone. We don't want unnecessary changes here.
So please revert the name changes everywhere in the PR

But the doc comments are a nice addition.

};
//# sourceMappingURL=types.d.ts.map
2 changes: 1 addition & 1 deletion dist/common/types.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/modules/transaction.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions dist/modules/transaction.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "teller",
"version": "0.1.0",
"name": "node-teller",
"version": "0.1.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it require a version change? Also even if so, it should be 0.1.1 why 0.1.5?

"description": "teller.io API client for nodejs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
20 changes: 16 additions & 4 deletions src/common/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
export type TellerOptionsBase = {
accessToken: string;
}
};

/**
* Using the latest Teller Version: 2020-10-12
*/
export type TellerOptionsPagination = TellerOptionsBase & {
cursor: string;
limit: number;
}
/**
* The maximum number of transactions to return in the API response.
*/
count?: number;
/**
* The transaction from where to start the page.
* The first transaction in the API response will be the one immediately before the transaction in the ledger with this id.
*
* example: txn_oiluj93igokseo0i3a005
*/
from_id?: string;
};
Comment on lines +9 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

21 changes: 10 additions & 11 deletions src/modules/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import type { TellerTransaction } from "../interfaces/transaction.js";
export default class TellerTransactionModule extends ClientBase {
async list(
accountId: string,
options?: TellerOptionsPagination,
options?: TellerOptionsPagination
): Promise<TellerTransaction[]> {
const searchParams =
options?.cursor && typeof options?.limit === "number"
? new URLSearchParams({
from_id: options?.cursor,
count: options?.limit?.toString(),
}).toString()
: null;
const params = Object.entries({
count: options?.count?.toString(),
from_id: options?.from_id,
}).filter((entry): entry is [string, string] => entry[1] != null);

const searchParams = new URLSearchParams(params);

const response = await this.axios.get(
`/accounts/${accountId}/transactions?${searchParams}`,
Expand All @@ -22,7 +21,7 @@ export default class TellerTransactionModule extends ClientBase {
? { username: options.accessToken, password: "" }
: undefined,
responseType: "json",
},
}
);

if (typeof response.data === "string") {
Expand All @@ -34,7 +33,7 @@ export default class TellerTransactionModule extends ClientBase {

async get(
{ accountId, id }: { id: string; accountId: string },
options?: TellerOptionsPagination,
options?: TellerOptionsPagination
): Promise<TellerTransaction> {
const response = await this.axios.get(
`/accounts/${accountId}/transactions/${id}`,
Expand All @@ -43,7 +42,7 @@ export default class TellerTransactionModule extends ClientBase {
? { username: options.accessToken, password: "" }
: undefined,
responseType: "json",
},
}
);

if (typeof response.data === "string") {
Expand Down