verys-javascript-sdk
v0.2.0
Published
Verys JavaScript SDK
Downloads
14
Readme
Verys JavaScript SDK
Browser and node module for making API requests against Verys JavaScript SDK.
Please note: This module uses Popsicle to make API requests. Promises must be supported or polyfilled on all target environments.
Installation
npm install verys-java-script-sdk --save
bower install verys-java-script-sdk --saveUsage
Node
var VerysJavaScriptSdk = require('verys-java-script-sdk');
var client = new VerysJavaScriptSdk();Browsers
<script src="verys-java-script-sdk/index.js"></script>
<script>
var client = new VerysJavaScriptSdk();
</script>Options
You can set options when you initialize a client or at any time with the options property. You may also override options for a single request by passing an object as the second argument of any request method. For example:
var client = new VerysJavaScriptSdk({ ... });
client.options = { ... };
client.resource('/').get(null, {
baseUri: 'http://example.com',
headers: {
'Content-Type': 'application/json'
}
});Base URI
You can override the base URI by setting the baseUri property, or initializing a client with a base URI. For example:
new VerysJavaScriptSdk({
baseUri: 'https://example.com'
});Base URI Parameters
If the base URI has parameters inline, you can set them by updating the baseUriParameters property. For example:
client.options.baseUriParameters.version = 'v1';Resources
All methods return a HTTP request instance of Popsicle, which allows the use of promises (and streaming in node).
resources.posts
var resource = client.resources.posts;GET
Fetch all posts
resource.get().then(function (res) { ... });POST
Create a new post
resource.post().then(function (res) { ... });resources.posts.id(Post ID)
- Post ID integer
var resource = client.resources.posts.id(Post ID);GET
Fetch a specific post
resource.get().then(function (res) { ... });PUT
Update a specific post
resource.put().then(function (res) { ... });DELETE
Delete a specific post
resource.delete().then(function (res) { ... });Custom Resources
You can make requests to a custom path in the API using the #resource(path) method.
client.resource('/example/path').get();License
Apache 2.0
