QUANDER NODE SDK
Installation
npm install quander-node-sdk
Usage
To write an app using the SDK
- Register for a developer account and get your client_id and secret.
- Add dependency 'quander-node-sdk' in your package.json file.
- Require 'quander-node-sdk' in your file
var Quander = Quander;
- Create config options, with parameters (mode, client_id, secret).
var quander = baseUrl: 'http://dev.quander.io/api' tokenUrl: 'http://dev.quander.io' clientId: '1a1t2u7b9540ggkk8s0gc4wcwcwwow40k4osw40cwo44swcoo0' clientSecret: '1a1t2u7b9540ggkk8s0gc4wcwcwwow40k4osw40cwo44swcoo0';
- Login with username/password
quander;
- If you already have your access token
quander;
How to use the resources
- Accessing your resources
var accountManager = quander;var projectManager = quander;
- getList operation
accountManager; // Using PaginationaccountManager; // Example of return for getList operation (ResourceCollection object)://{// "data": [// {// "id": 115,// ...// },// {// "id": 34,// ...// }// ],// "page": 1,// "limit": 100,// "pages": 1,// "total": 2//}
- get operation ".get(uuid)"
accountManager;
- post operation ".post(payload, data)"
mediaManager; // Post multipart/form-data with the payload and filesmediaManager;
Available Resources and Operations
- Account => getList, get, post
- Project(account) => getList
- Experience(project) => getList
- Media(project) => getList
- Media(attendee) => getList
- Media(experience) => post
- Attendee(project) => post
Handling Error
There are 2 types of error, one coming from the sdk (QuanderSdkError), and the other one from the api responses (QuanderApiError).
accountManager;
- Example: Handling expired token
try quander; catch e if e instanceof QuanderSdkError && QuanderSdkErrorTOKEN_EXPIRED === eerrorCode // Call the api to request the new access token return quander;
Available Errors
- QuanderSdkError
Key | Description |
---|---|
BAD_RESOURCE | Resource not supported by the sdk |
BAD_OPERATION | Operation not supported by the sdk |
TOKEN_EXPIRED | Token is expired, you should request a new one through the api |
- QuanderApiError
Key | Description |
---|---|
INVALID_GRANT | You can't authenticate with that method |
REFRESH_TOKEN_INVALID | Your refresh token is invalid, you have to authenticate again |
BAD_REQUEST | General error. The server cannot or will not process the request. |
FORBIDDEN | The request was a valid request, but the server is refusing to respond to it. |
NOT_FOUND | Resource could not be found but may be available in the future. |
CONFLICT | Indicates that the request could not be processed because of conflict in the request. |
Debugging
- Enable debug
Quander;