Install the latest stable release of this module from npmjs.org:
npm install goodscloud
Or install the development version from github.com with:
npm install git+https://github.com/goodscloud/goodscloud-node.git
This package depends on the utf8 package and the request package by Mikeal Rogers. These should be downloaded and installed by npm
when installing this package, but if they are not, install them with:
npm install utf8
npm install request
Use the client like this:
var Client = require('goodscloud');
var c = new Client('http://sandbox.goodscloud.com');
c.login('me@mycompany.com', 'PASSWORD',
function () {
console.info("Logged in as", c.email);
c.get('/api/internal/company', {flat: true}, function (data) {
console.info(data);
});
}
);
Function calls corresponding to HTTP
method verbs have different optional arguments. In all cases, providing a callback
is optional. If no callback
is provided, the request will be executed but the response data will be discarded.
Client.get()
allows the following call signatures:get(endpoint);
get(endpoint, params);
get(endpoint, callback);
get(endpoint, params, callback);
Client.put()
andClient.post()
always require adata
argument to be provided. They allow the following call signatures:func(endpoint, data);
func(endpoint, params, data);
func(endpoint, data, callback);
func(endpoint, params, data, callback);
Client.patch()
always requires bothparams
anddata
arguments to be provided. It allows the following call signatures:patch(endpoint, params, data);
patch(endpoint, params, data, callback);
Client.delete()
allows the following call signatures:delete(endpoint);
delete(endpoint, callback);
Product images and shipping labels are stored on Amazon S3. By default the API client doesn't get AWS credentials issued. To get AWS enabled client set use_aws
option to true
when instantiating the client:
var Client = require('goodscloud');
var c = new Client('http://sandbox.goodscloud.com', {use_aws: true});
c.login('me@mycompany.com', 'PASSWORD',
function () {
var params = {
results_per_page: 1
};
c.get('/api/internal/product_image', params, function (data) {
var product_image = data.objects[0];
console.log(c.build_product_image_url(product_image.url_fragment));
});
}
);
Release a new version like this:
- Update the version number in
package.json
- Log in to npmjs.org with
npm adduser
- Publish the package with
npm publish
You won't be able to upload a new package if you're not one of the package owners. To become an owner you need to do several things:
- Create an account on
https://www.npmjs.com
if you don't have one already - Ask one of the existing owners to add you as an owner. To get list of existing owners run this command
npm owner ls