Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lunch-money

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lunch-money - npm Package Compare versions

Comparing version 0.0.1 to 0.5.0

66

dist/index.d.ts
export interface Asset {
id: number;
type_name: string;
subtype_name?: string;
type_name: "employee compensation" | "cash" | "vehicle" | "loan" | "cryptocurrency" | "investment" | "other" | "credit" | "real estate";
subtype_name?: string | null;
name: string;
balance: number;
institution_name?: string;
display_name?: string | null;
balance: string;
balance_as_of: string;
currency: string;
closed_on?: string | null;
institution_name?: string | null;
created_at: string;
}
export interface AssetUpdate {
id: number;
type_name?: "employee compensation" | "cash" | "vehicle" | "loan" | "cryptocurrency" | "investment" | "other" | "credit" | "real estate";
subtype_name?: string | null;
name?: string;
display_name?: string | null;
balance?: string;
balance_as_of?: string;
currency?: string;
institution_name?: string | null;
}
export interface PlaidAccount {
id: number;
date_linked: string;
name: string;
type: "credit" | "depository" | "brokerage" | "cash" | "loan" | "investment";
subtype?: string | null;
mask: string;
institution_name: string;
status: "active" | "inactive" | "relink" | "syncing" | "error" | "not found" | "not supported";
last_import?: string | null;
balance: string;
currency: string;
balance_last_update: string;
limit?: number | null;
}
export interface Transaction {

@@ -26,2 +57,14 @@ id: number;

}
export interface Category {
id: number;
name: string;
description: string;
is_income: boolean;
exclude_from_budget: boolean;
exclude_from_totals: boolean;
updated_at: string;
created_at: string;
is_group: boolean;
group_id?: number;
}
export interface DraftTransaction {

@@ -46,2 +89,3 @@ date: string;

end_date?: string;
tag_id?: number;
debit_as_negative?: boolean;

@@ -52,3 +96,3 @@ }

}
export default class LunchMoney {
export declare class LunchMoney {
token: string;

@@ -60,7 +104,15 @@ constructor(args: {

post(endpoint: string, args?: EndpointArguments): Promise<any>;
put(endpoint: string, args?: EndpointArguments): Promise<any>;
delete(endpoint: string, args?: EndpointArguments): Promise<any>;
request(method: "GET" | "POST" | "PUT" | "DELETE", endpoint: string, args?: EndpointArguments): Promise<any>;
getAssets(): Promise<Asset[]>;
updateAsset(endpointArgs: AssetUpdate): Promise<any>;
getPlaidAccounts(): Promise<PlaidAccount[]>;
getTransactions(args?: TransactionsEndpointArguments): Promise<Transaction[]>;
createTransactions(transactions: DraftTransaction[], applyRules?: boolean, checkForRecurring?: boolean, debitAsNegative?: boolean): Promise<any>;
getTransaction(id: number, args?: EndpointArguments): Promise<Transaction>;
updateTransaction(id: number, transaction: any): Promise<any>;
getCategories(): Promise<Category[]>;
createCategory(name: string, description: string, isIncome: boolean, excludeFromBudget: boolean, excludeFromTotals: boolean): Promise<any>;
createTransactions(transactions: DraftTransaction[], applyRules?: boolean, checkForRecurring?: boolean, debitAsNegative?: boolean, skipBalanceUpdate?: boolean): Promise<any>;
}
export {};
export default LunchMoney;

@@ -15,2 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.LunchMoney = void 0;
const isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch"));

@@ -32,2 +33,12 @@ const base = 'https://dev.lunchmoney.app';

}
put(endpoint, args) {
return __awaiter(this, void 0, void 0, function* () {
return this.request('PUT', endpoint, args);
});
}
delete(endpoint, args) {
return __awaiter(this, void 0, void 0, function* () {
return this.request('DELETE', endpoint, args);
});
}
request(method, endpoint, args) {

@@ -37,3 +48,6 @@ return __awaiter(this, void 0, void 0, function* () {

if (method === 'GET' && args) {
url += '?' + Object.entries(args).map(([key, value]) => `${key}=${value}`);
url += '?';
url += Object.entries(args)
.map(([key, value]) => `${key}=${value}`)
.join('&');
}

@@ -51,3 +65,3 @@ const headers = new Headers();

}
const response = yield isomorphic_fetch_1.default(url, options);
const response = yield (0, isomorphic_fetch_1.default)(url, options);
if (response.status > 399) {

@@ -64,5 +78,15 @@ const r = yield response.text();

return __awaiter(this, void 0, void 0, function* () {
return this.get('/v1/assets');
return (yield this.get('/v1/assets')).assets;
});
}
updateAsset(endpointArgs) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.put('/v1/assets/' + endpointArgs.id, endpointArgs));
});
}
getPlaidAccounts() {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.get('/v1/plaid_accounts')).plaid_accounts;
});
}
getTransactions(args) {

@@ -73,4 +97,31 @@ return __awaiter(this, void 0, void 0, function* () {

}
createTransactions(transactions, applyRules = false, checkForRecurring = false, debitAsNegative = false) {
getTransaction(id, args) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.get('/v1/transactions/' + id, args));
});
}
updateTransaction(id, transaction) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.put('/v1/transactions/' + id, { transaction: transaction }));
});
}
getCategories() {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.get('/v1/categories')).categories;
});
}
createCategory(name, description, isIncome, excludeFromBudget, excludeFromTotals) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.post('/v1/categories', {
name,
description,
is_income: isIncome,
exclude_from_budget: excludeFromBudget,
exclude_from_totals: excludeFromTotals
});
return response;
});
}
createTransactions(transactions, applyRules = false, checkForRecurring = false, debitAsNegative = false, skipBalanceUpdate = true) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.post('/v1/transactions', {

@@ -80,3 +131,4 @@ transactions: transactions,

check_for_recurring: checkForRecurring,
debit_as_negative: debitAsNegative
debit_as_negative: debitAsNegative,
skip_balance_update: skipBalanceUpdate,
});

@@ -87,2 +139,3 @@ return response;

}
exports.LunchMoney = LunchMoney;
exports.default = LunchMoney;

@@ -6,10 +6,66 @@ import fetch from 'isomorphic-fetch';

export interface Asset {
id: number,
type_name: string,
subtype_name?: string,
name: string,
balance: number,
institution_name?: string,
id: number;
type_name: "employee compensation"
| "cash"
| "vehicle"
| "loan"
| "cryptocurrency"
| "investment"
| "other"
| "credit"
| "real estate";
subtype_name?: string | null;
name: string;
display_name?: string | null;
balance: string;
balance_as_of: string;
currency: string;
closed_on?: string | null;
institution_name?: string | null;
created_at: string;
}
export interface AssetUpdate {
id: number;
type_name?: "employee compensation"
| "cash"
| "vehicle"
| "loan"
| "cryptocurrency"
| "investment"
| "other"
| "credit"
| "real estate";
subtype_name?: string | null;
name?: string;
display_name?: string | null;
balance?: string;
balance_as_of?: string;
currency?: string;
institution_name?: string | null;
}
export interface PlaidAccount {
id: number;
date_linked: string;
name: string;
type: "credit" | "depository" | "brokerage" | "cash" | "loan" | "investment";
subtype?: string | null;
mask: string;
institution_name: string;
status:
| "active"
| "inactive"
| "relink"
| "syncing"
| "error"
| "not found"
| "not supported";
last_import?: string | null;
balance: string;
currency: string;
balance_last_update: string;
limit?: number | null;
}
export interface Transaction {

@@ -33,2 +89,15 @@ id: number,

export interface Category {
id: number,
name: string,
description: string,
is_income: boolean,
exclude_from_budget: boolean,
exclude_from_totals: boolean,
updated_at: string,
created_at: string,
is_group: boolean,
group_id?: number,
}
export interface DraftTransaction {

@@ -55,2 +124,3 @@ date: string,

end_date?: string,
tag_id?: number,
debit_as_negative?: boolean,

@@ -63,3 +133,3 @@ }

export default class LunchMoney {
export class LunchMoney {
token: string;

@@ -78,7 +148,17 @@ constructor( args: { token: string } ) {

async put( endpoint: string, args?: EndpointArguments ) {
return this.request( 'PUT', endpoint, args );
}
async delete(endpoint: string, args?: EndpointArguments) : Promise<any> {
return this.request( 'DELETE', endpoint, args );
}
async request( method: "GET" | "POST" | "PUT" | "DELETE", endpoint: string, args?: EndpointArguments ) {
let url = `${ base }${ endpoint }`;
if ( method === 'GET' && args ) {
url += '?' + Object.entries( args ).map( ( [ key, value ] ) => `${ key }=${ value }` )
url += '?';
url += Object.entries( args )
.map( ( [ key, value ] ) => `${ key }=${ value }` )
.join( '&' );
}

@@ -107,5 +187,13 @@ const headers = new Headers();

async getAssets() : Promise<Asset[]> {
return this.get( '/v1/assets' );
return (await this.get( '/v1/assets' )).assets;
}
async updateAsset( endpointArgs: AssetUpdate ) : Promise<any> {
return ( await this.put( '/v1/assets/' + endpointArgs.id, endpointArgs) );
}
async getPlaidAccounts() : Promise<PlaidAccount[]> {
return ( await this.get( '/v1/plaid_accounts' ) ).plaid_accounts;
}
async getTransactions( args?: TransactionsEndpointArguments ) : Promise<Transaction[]> {

@@ -115,3 +203,27 @@ return ( await this.get( '/v1/transactions', args ) ).transactions;

async createTransactions( transactions: DraftTransaction[], applyRules = false, checkForRecurring = false, debitAsNegative = false ) : Promise<any> {
async getTransaction( id: number, args?: EndpointArguments ) : Promise<Transaction> {
return ( await this.get( '/v1/transactions/' + id, args ) );
}
async updateTransaction(id: number, transaction: any) : Promise<any> {
return ( await this.put( '/v1/transactions/' + id, { transaction: transaction } ) );
}
async getCategories( ) : Promise<Category[]> {
return ( await this.get( '/v1/categories' ) ).categories;
}
async createCategory( name: string, description: string, isIncome: boolean, excludeFromBudget: boolean, excludeFromTotals: boolean ) : Promise<any> {
const response = await this.post( '/v1/categories', {
name,
description,
is_income: isIncome,
exclude_from_budget: excludeFromBudget,
exclude_from_totals: excludeFromTotals
} );
return response;
}
async createTransactions( transactions: DraftTransaction[], applyRules = false, checkForRecurring = false, debitAsNegative = false, skipBalanceUpdate = true ) : Promise<any> {
const response = await this.post( '/v1/transactions', {

@@ -121,3 +233,4 @@ transactions: transactions,

check_for_recurring: checkForRecurring,
debit_as_negative: debitAsNegative
debit_as_negative: debitAsNegative,
skip_balance_update: skipBalanceUpdate,
} );

@@ -128,1 +241,4 @@

}
export default LunchMoney;

18

package.json
{
"name": "lunch-money",
"version": "0.0.1",
"description": "",
"version": "0.5.0",
"description": "API bindings for the Lunch Money personal finance application",
"type": "commonjs",
"main": "dist/index.js",

@@ -19,2 +20,9 @@ "scripts": {

"author": "Joe Hoyle",
"contributors": [
{
"name": "Michael Bianco",
"email": "mike@mikebian.co",
"url": "https://mikebian.co/about"
}
],
"license": "MIT",

@@ -27,9 +35,9 @@ "bugs": {

"@types/isomorphic-fetch": "^0.0.35",
"@types/node": "^13.9.3",
"typescript": "^3.8.3"
"@types/node": "^16.11.0",
"typescript": "^4.4.4"
},
"types": "dist/index.d.ts",
"dependencies": {
"isomorphic-fetch": "^2.2.1"
"isomorphic-fetch": "^3.0.0"
}
}

@@ -9,4 +9,2 @@ # Lunch Money JS

(waiting NPM approval, not yet working!)
The NPM module also makes types available to TypeScript.

@@ -28,5 +26,13 @@

Or, if you are using ESM:
```javascript
import {LunchMoney} from 'lunch-money'
const lunchMoney = new LunchMoney( { token: 'my-api-token' } );
const assets = await lunchMoney.getAssets();
```
## API
Get all assets
Get all assets (manually managed accounts):

@@ -37,3 +43,3 @@ ```typescript

Get all transactions
Get all transactions:

@@ -54,1 +60,7 @@ ```typescript

```
## Examples
There are many open source projects with example code you can use to quickly build your integration:
https://lunchmoney.dev/#awesome-projects
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc