Skip to content

Commit

Permalink
Switch to Standard JS
Browse files Browse the repository at this point in the history
  • Loading branch information
keriwarr committed Nov 13, 2017
1 parent f4b20ee commit 5b61a77
Show file tree
Hide file tree
Showing 8 changed files with 600 additions and 1,270 deletions.
8 changes: 0 additions & 8 deletions .eslintrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -56,3 +56,6 @@ typings/

# dotenv environment variables file
.env

# opting in favour of yarn.lock
package-lock.json
10 changes: 0 additions & 10 deletions .prettierrc.js

This file was deleted.

40 changes: 20 additions & 20 deletions README.md
Expand Up @@ -23,38 +23,38 @@ Register your splitwise application [here](https://secure.splitwise.com/oauth_cl
### Step 3:

```javascript
const { Splitwise } = require('splitwise');
const { Splitwise } = require('splitwise')
const sw = new Splitwise({
clientKey: 'your key here',
clientSecret: 'your secret here',
});
clientSecret: 'your secret here'
})

sw.getCurrentUser().then(console.log);
sw.getCurrentUser().then(console.log)
```

## Non-trivial example

In this example, we create a new expense from the current user, to the first listed user in the given group, with the same description as the first given expense.

```javascript
const { Splitwise } = require('splitwise');
const { Splitwise } = require('splitwise')
const sw = new Splitwise({
consumerKey: 'your key here',
consumerSecret: 'your secret here',
});
const groupID = '12345678';
consumerSecret: 'your secret here'
})
const groupID = '12345678'

Promise.all([
sw.getGroup({ groupID: groupID }),
sw.getExpenses({ groupID: groupID }),
sw.getCurrentUser(),
sw.getCurrentUser()
]).then(([group, expenses, me]) => sw.createDebt({
from: group.members[0].id,
to: me.id,
groupID: groupID,
description: expenses[0].description,
amount: 100,
}));
amount: 100
}))
```

## Documentation
Expand All @@ -69,7 +69,7 @@ You may optionally pass in the following parameters: `groupID`, `userID`, `expen

```javascript
const sw = new Splitwise({
...
// ...
groupID: '12345678',
});

Expand All @@ -83,7 +83,7 @@ For any of the API methods documented on Splitwise's website, you can use it by
For some group methods such as `getGroup` you must pass in a groupID:

```javascript
sw.getGroup({ groupID: '12345678' }).then(...);
sw.getGroup({ groupID: '12345678' }).then();
```

For some expense methods, user methods, and friend methods, you must do the same.
Expand All @@ -94,18 +94,18 @@ Splitwise makes some important notes about their API that booleans, and nested p
sw.createExpense({
users__0__user_id: '23456789',
users__1__users_id: '34567890',
payment: 0,
});
payment: 0
})
```
You make simply do:
```javascript
sw.createExpense({
users: [
{ user_id: '23456789' },
{ user_id: '34567890' },
{ user_id: '34567890' }
],
payment: false,
});
payment: false
})
```

And on that note...
Expand All @@ -119,8 +119,8 @@ sw.createDebt({
from: '23456789',
to: '34567890',
amount: 100,
description: 'yay!',
});
description: 'yay!'
})
```

## Notes
Expand Down

0 comments on commit 5b61a77

Please sign in to comment.