Gambio API Client for Node.js
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
- Get a specific country - API.countries.getById(id)
- Get zones from a specific country - API.countries.getZonesByCountryId(id)
Zones
- Get a specific zone - API.zones.getById(id)
Addresses
- Get a specific address - API.addresses.getById(id)
- Create a new address - API.addresses.create(data)
- Delete an address - API.addresses.deleteById(id)
- Update an address - API.addresses.updateById(id, data)
Customers
- Get all customers - API.customers.get()
- Get all customers, that are guests - API.customers.getGuests()
- Get a specific customer - API.customers.getById(id)
- Get addresses from a specific customer - API.customers.getAddressesByCustomerId(id)
- Search in customers - API.customers.search(term)
- Create a new customer - API.customers.create(data)
- Delete a customer - API.customers.deleteById(id)
- Update a customer - API.customers.updateById(id, data)
E-Mails
- Get all E-Mails - API.emails.get()
- Get all pending E-Mails - API.emails.getPending()
- Get all sent E-Mails - - API.emails.getSent()
- Get a specific E-Mail - API.emails.getById(id)
- Search in E-Mails - API.emails.search(term)
- Delete an E-Mail - API.emails.deleteById(id)
- Queue an E-Mail - API.emails.queue(data)
- Send an E-Mail - API.emails.send([id], [data])
Categories
- Create a new category - API.categories.create(data)
- Delete category icon - API.categories.deleteIcon(file)
- Delete category image - API.categories.deleteImage(file)
- Delete a category - API.categories.deleteById(id)
- Get all categories - API.categories.get()
- Get a specific category - API.categories.getById(id)
- Search in categories - API.categories.search(term)
- Rename category icon - API.categories.renameIcon(oldName, newName)
- Rename category image - API.categories.renameImage(oldName, newName)
- Update a category - API.categories.updateById(id, data)
- Upload a category icon - API.categories.uploadIcon(path, name)
- Upload a category image - API.categories.uploadImage(path, name)
Orders
- Create a new order item attribute - API.orders.createItemAttribute(orderId, itemId, data)
- Create a new order item - API.orders.createItem(orderId, data)
- Create a new order total - API.orders.createTotal(orderId, data)
- Create a new order - API.orders.create(data)
- Delete order item attribute - API.orders.deleteItemAttributeById(data)
- Delete order item - API.orders.deleteItemById(orderId, itemId)
- Delete order total - API.orders.deleteTotalById(orderId, totalId)
- Delete order - API.orders.deleteById(id)
- Get order status history records - API.orders.getHistory(orderId)
- Get an order status history record - API.orders.getHistoryById(orderId, historyId)
- Search in order status history - API.orders.searchHistory(orderId, term)
- Get order item attributes - API.orders.getItemAttributes(orderId, itemId)
- Get an order item attribute - API.orders.getItemAttributeById(orderId, itemId, attributeId)
- Search in order item attributes - API.orders.searchItemAttributes(orderId, itemId, term)
- Get order items - API.orders.getItems(orderId)
- Get an order item - API.orders.getItemById(orderId, itemId)
- Search in order items - API.orders.searchItems(orderId, term)
- Get order totals - API.orders.getTotals(orderId)
- Get an order total - API.orders.getTotalById(orderId, totalId)
- Search in order totals - API.orders.searchTotals(orderId, term)
- Get all orders - API.orders.get()
- Get an order - API.orders.getById(id)
- Search in orders - API.orders.search(term)
- Update an order item attribute - API.orders.updateItemAttributeById(orderId, itemId, attributeId, data)
- Update an order item - API.orders.updateItemById(orderId, itemId, data)
- Update an order status - API.orders.updateStatus(orderId, data)
- Update an order total - API.orders.updateTotalById(orderId, totalId, data)
- Update an order - API.orders.updateById(id, data)
Products
- Change product to category link - API.products.changeCategoryLink(id, oldCategoryId, newCategoryId)
- Create a new product - API.products.create(data)
- Delete a product image - API.products.deleteImage(file)
- Delete a product - API.products.deleteById(id)
- Get product to category links - API.products.getCategoryLinks(id)
- Get products - API.products.get()
- Get a product - API.products.getById(id)
- Search in products - API.products.search(term)
- Rename a product image - API.products.renameImage(oldName, newName)
- Update a product - API.products.updateById(id, data)
- Upload a new product image - API.products.uploadImage(path, name)
API
- Get module version - API.getVersion()
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