Front end client for zendesk
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;
}
});
Creates a client for the front end.
Param | Type | Description |
---|---|---|
subdomain | string |
the subdomain for your account |
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 |
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 |