Skip to content

aweber/zendesk-requests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zendesk-requests

Front end client for zendesk

Documentation

Quickstart example:

import ZendeskRequests, { RequestsError } from '@aweber/zendesk-requests';

const requests = new ZendeskRequests('mysubdomain');
const promise = requests.create({
    requester: {
        name: 'Anonymous'
    },
    subject: 'Request subject',
    comment: {
        body: 'This is the body'
    }
});
promise.catch((e) => {
    if(e instanceof RequestsError &&
            e.status === 422 &&
            e.json.error === 'RecordInvalid') {
        // Handle validation error
    } else {
        throw e;
    }
});

API

new RequestsClient(subdomain)

Creates a client for the front end.

Param Type Description
subdomain string the subdomain for your account

RequestsClient.create(request) ⇒ Promise.<Object, Error>

Creates an anonymous Zendesk request.

Returns: Promise.<Object, Error> - the zendesk request that was created is resolved by the promise, else it throws a RequestsError

Param Type Description
request Object request object as documented in zendesk

RequestsError

Thrown when a non-successful HTTP status was returned.

Key Description
message Response body text
status HTTP status code
json Response body as JSON, or null if not valid JSON