Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Latest commit

 

History

History
executable file
·
109 lines (77 loc) · 3.28 KB

README.md

File metadata and controls

executable file
·
109 lines (77 loc) · 3.28 KB

okra-node

This is a npm module that abstracts the complexity of using okra with node.

USAGE

1. Install the module

Install with yarn:

yarn add okra-node

but you can use npm if you like:

npm install --save okra-node

2. Import the module

In your app.js or any module where the component would be used:

import * as okra_client from "okra-node";

or import the class that you need:

import { Accounts } from "okra-node";

3. Implementation

Okra Node exposes all the API endpoint that are available in Okra docs (https://docs.okra.ng/reference/). Please find the parameters you can pass to the endpoints in the API refenece mentioned above.

4. Okra Classes

The Okra Node Client is devided to classes that can be consumed sepratley as it's necessary for you. The classes are inheriting Okra Client class, so you'll need to pass the enviornment and Okra Secret (found here: https://dash.okra.ng/settings/api-keys) to each class you implement.

Each function of the class will intake an options object as argument. The object can contain different parameters that you would like to return, for example, you can pass the object: {id: "1234567890"} to Auth.get() and it will point that request to the correct endpoint.

Examples

  • list accounts:
const accounts = new Accounts(okraSecret, env);
const getAccounts = accounts.get()
  • get account by id:
const accountId = { id: 'bb11189898kll' }
const accounts = new Accounts(okraSecret, env);
const getAccounts = accounts.get(accountId);
  • check balance:
const options = {account_id: "bbb118989kll", record_id: "ccc1144090987"}
const balances = new Balance(okraSecret, env);
const checkBalance = balances.check(options)

5. Pagination

If pagination is available, you can call the next and previous page via the .nextPage() or .prevPage() derivited from the resposne object.

Example:

const reports = new Reports(okraSecret, env);

const getReports = reports.get();
const getNextPage = getReports.nextPage();
  • Auth: Allows you to get information on extisting authentication.

Available options:

For more information checkout okra's documentation

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

License

The MIT License (MIT). Please see License File for more information.