gambio-api

Gambio API Client for Node.js


License
GPL-2.0
Install
npm install gambio-api@3.0.0

Documentation

Logo

Gambio API Client for Node.js

Build Status NPM

Simple API client for Node, that performs requests to the integrated REST-API of Gambio.

Table of contents

Installation

npm install gambio-api

Usage

import GambioApi from 'gambio-api';

const API = new GambioApi({
  url: 'https://myshop.com',
  user: 'admin@myshop.com',
  pass: '12345',
});

API.customers.getById(6)
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

You may also read an article on how to use this module.

Creating a new instance

const API = new GambioApi({
  // Path to Gambio shop (without trailing slash).
  url: 'http://myshop.com',
  // Login user.
  user: 'admin@myshop.com',
  // Login password.
  pass: '12345',
});

Performing a request

The methods always return a promise.

API.customers.get()
  // 'then' is called, if a response is returned from server.
  .then()

  // 'catch' is called if an error has been thrown.
  .catch();

Response

Every successful response is parsed from JSON to a plain JavaScript object/array.

// Example request.
API.customers.getById(1).then(console.log);

Example console output could be:

{
  id: 1,
  number: '',
  gender: 'm',
  firstname: 'Tester',
  lastname: 'Tester',
  dateOfBirth: '0000-00-00',
  vatNumber: '',
  vatNumberStatus: 0,
  telephone: '0123456789',
  fax: '',
  email: 'admin@shop.de',
  statusId: 0,
  isGuest: false,
  addressId: 1
}

Error

If an HTTP status code between 300 and 600 is returned from server, the promise will be rejected with an error.

All reject error objects have a data property which contains the raw request and response data.

API reference

Countries

Zones

Addresses

Customers

E-Mails

Categories

Orders

Products

API

Contributing

Pull requests are always welcome!

Read contribution docs for more information about contributing to this project.

License

Copyright (c) 2016 Ronald Loyko

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

For the complete terms of the GNU General Public License, please see this URL: http://www.gnu.org/licenses/gpl-2.0.html