https://github.com/trolley/javascript-sdk
Trolley SDK for JavaScript
https://github.com/trolley/javascript-sdk
javascript-sdk sdk trolley-sdk typescript
Last synced: 2 months ago
JSON representation
Trolley SDK for JavaScript
- Host: GitHub
- URL: https://github.com/trolley/javascript-sdk
- Owner: trolley
- Created: 2018-01-08T18:49:39.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-12-19T17:10:49.000Z (over 1 year ago)
- Last Synced: 2025-10-20T01:17:55.979Z (5 months ago)
- Topics: javascript-sdk, sdk, trolley-sdk, typescript
- Language: TypeScript
- Homepage: https://trolley.com
- Size: 728 KB
- Stars: 7
- Watchers: 8
- Forks: 5
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Trolley JavaScript SDK
Trolley's JavaScript SDK (written in TypeScript) - For more information about the API as well as NodeJS code samples check out the [full API documentation](https://docs.trolley.com)
## Installation
npm install --save trolleyhq
## Getting Started
The Trolley API is built using promises and all methods except
connect will return a promise. The connect call allows you to setup
your API Key and Secret with a client that can be used for subsequent
calls.
```js
// A simple application using the Trolley/Payment Rails SDK
const trolley = require('trolleyhq');
const client = trolley.connect({
key: "YOUR-ACCESS-KEY",
secret: "YOUR-SECRET-SECRET",
});
// Async/Await version
async function main() {
const recipient = await client.recipient.find("R-G7SXXpm6cs4aTUd9YhmgWC");
console.log(recipient.id);
}
main();
// Promise version
client.recipient.find("R-G7SXXpm6cs4aTUd9YhmgWC").then(recipient => {
console.log(recipient.id);
}).catch(err => {
console.log("ERROR", err);
});
```
### Usage
Methods should all have JSDoc comments to help you understand their usage. As mentioned the [full API documentation](https://docs.trolley.com)
is the best source of information about the API.
For more information please read the [JavaScript API docs](https://github.com/Trolley/javascript-sdk/blob/master/docs/) is available. The best starting point is:
| Data Type | SDK Documentation |
| ----- | ----- |
| Batch | [API Docs for Batch](https://github.com/Trolley/javascript-sdk/blob/master/docs/classes/batchgateway.md) |
| Payment | [API Docs for Payment](https://github.com/Trolley/javascript-sdk/blob/master/docs/classes/paymentgateway.md) |
| Recipient | [API Docs for Recipient](https://github.com/Trolley/javascript-sdk/blob/master/docs/classes/recipientgateway.md) |
| Recipient Account | [API Docs for Recipient Account](https://github.com/Trolley/javascript-sdk/blob/master/docs/classes/recipientaccountgateway.md) |
### Running Integration / Unit tests
If you're working on the library itself, here's easy way to run the tests.
```
// if not already, copy the example env file to create an env file
$ cp .env.test .env
// Set access key and secret in the env file
TROLLEY_ACCESS_KEY="ACCESS_KEY"
TROLLEY_SECRET_KEY="SECRET_KEY"
//Run the fixture based tests
$ npm test
```