1.2.2 • Published 5 years ago

unodoku-nodejs v1.2.2

Weekly downloads
6
License
ISC
Repository
github
Last release
5 years ago

Unofficial Doku JavaScript (NodeJS) Library

NPM

npm version Build Status NPM download/month NPM download total

This is an Unofficial JavaScript (NodeJS) API client/library for Doku Core API. Visit https://www.doku.com/API for more technical details.

1. Installation

1.a Using NPM

npm install --save unodoku-nodejs

1.b Manual Installation

If you are not using NPM, you can clone or download this repository. Then require from api.js file.

const DokuApi = require('./unodoku-nodejs/api')

2. Usage

2.1 Client Initialization and Configuration

Set your sharedKey and mallId

Create API client object

const DokuApi = require('unodoku-nodejs')
// Create Core API instance
let doku = new DokuApi({
    isProduction : false,
    sharedKey : 'YOUR_SHARED_KEY',
    mallId : 'YOUR_MALL_ID'
})

You can also re-set config using DokuApi.config.set( ... ) example:

const DokuApi = require('unodoku-nodejs')
// Create Core API instance
let doku = new DokuApi()
doku.config.set({
    isProduction : false,
    sharedKey : 'YOUR_SHARED_KEY',
    mallId : 'YOUR_MALL_ID'
})

// You don't have to re-set using all the options, 
// i.e. set sharedKey only
doku.config.set({sharedKey : 'YOUR_SHARED_KEY'})

You can also set config directly from attribute

const DokuApi = require('unodoku-nodejs')
// Create Core API instance
let doku = new DokuApi()

doku.config.isProduction = false
doku.config.sharedKey = 'YOUR_SHARED_KEY'
doku.config.mallId = 'YOUR_MALL_ID'

3. Handling Error / Exception

When using function that result in Doku API call e.g: DokuApi.doGeneratePaycode(...) there's a chance it may throw error (ApiError object), the error object will contains below properties that can be used as information to your error handling logic:

doku.doGeneratePaycode(payload)
    .then((res)=>{
    })
    .catch((e)=>{
        e.message // Basic error message string
        e.httpStatusCode // HTTP status code e.g: 400, 401, etc.
        e.httpResponseData // HTTP response data
        e.rawHttpClient // raw Axios response object
    })
1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago