$request(payload, callback) {
        let options = {
            uri: this.$uri,
            headers: this.$headers,
            data: payload && JSON.stringify(payload)
        };

        post(options)
            .then(function (data) {
                try {
                    data = JSON.parse(data).RESPONSE;
                } catch (e) {
                    return callback(
                        new Error.FastbillInvalidRequestError({
                            message: 'Unable to parse response',
                            detail: e
                        }));
                }

                // Check if the FastBill API responds with errors
                // If so, create an error object with the first available error message.
                if (data.ERRORS) {
                    return callback(new Error(data.ERRORS[0]));
                }
                callback(null, data);
            })
            .catch(function (err) {
                return callback(err, null);
            });
    }
/**
     * Performs a HTTP request against the FastBill API.
     *
     * @param {object} payload The request pattern (e.g. filter, data, service, etc.)
     * @param {function} callback Error-first callback (err, parsedResultSet)
     *
     */
Performs a HTTP request against the FastBill API.
@param {object} payload The request pattern
@param {function} callback Error-first callback (err, parsedResultSet)
Performs a HTTP request against the FastBill API . @param { object } payload The request pattern @param { function } callback Error - first callback ( err parsedResultSet )
$request(payload, callback) {
        let options = {
            uri: this.$uri,
            headers: this.$headers,
            data: payload && JSON.stringify(payload)
        };
        post(options)
            .then(function (data) {
                try {
                    data = JSON.parse(data).RESPONSE;
                } catch (e) {
                    return callback(
                        new Error.FastbillInvalidRequestError({
                            message: 'Unable to parse response',
                            detail: e
                        }));
                }
                if (data.ERRORS) {
                    return callback(new Error(data.ERRORS[0]));
                }
                callback(null, data);
            })
            .catch(function (err) {
                return callback(err, null);
            });
    }
$request ( payload , callback ) { let options = { uri : this . $uri , headers : this . $headers , data : payload && JSON . stringify ( payload ) } ; post ( options ) . then ( function ( data ) { try { data = JSON . parse ( data ) . RESPONSE ; } catch ( e ) { return callback ( new Error . FastbillInvalidRequestError ( { message : 'Unable to parse response' , detail : e } ) ) ; } if ( data . ERRORS ) { return callback ( new Error ( data . ERRORS [ 0 ] ) ) ; } callback ( null , data ) ; } ) . catch ( function ( err ) { return callback ( err , null ) ; } ) ; }
Performs a HTTP request against the FastBill API.
Performs a HTTP request against the FastBill API .
// Check if the FastBill API responds with errors // If so, create an error object with the first available error message.