Coder Social home page Coder Social logo

xreader / node-gambio-api-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benmountain/node-gambio-api-client

0.0 1.0 0.0 131 KB

Node client for the Gambio REST API

Home Page: http://developers.gambio.de

License: MIT License

JavaScript 60.74% TypeScript 39.26%

node-gambio-api-client's Introduction

Node client for the Gambio REST API Build Status npm version

Performs requests to the integrated RESTful API of the Gambio shop system.

Features

  • Easy-to-read API
  • Usage of Promises for chainable operations
  • Fully tested (Unit and E2E tests)

To see a detailed list of recent changes please take a look into the changelog.

Table of contents

Installation

npm install gambio-api-client

Usage

Creating an instance

To create a client instance you need to pass in the shop URL, administrator user and password credentials.

import Client from 'gambio-api-client';

const instance = new Client({
  url: 'https://www.gambio-shop.de/shop2',
  user: '[email protected]',
  password: '12345',
});

Returning the client version

To get the client version just access the static class property VERSION .

const version = Client.VERSION;

Performing requests

You have access to the all resources described in the API documentation.

All methods return a Promise object, that are thenable and catchable.

Simple example: Getting all existing customers

instance.customers.get()
	.then(customers => console.log(customers))
	.catch(error => console.error(error));

More complex example: Deleting all addresses of customer 'John Doe'

function findJohnDoe(customer) {
  return (customer.firstname === 'John' && customer.lastname === 'Doe');
}

function deleteAllAddressesOfCustomer(addresses) {
  const promises = [];
  addresses.forEach(address => promises.push(instance.addresses.delete(address.id)));
  return Promise.all(promises)
}

instance.customers.search('Doe')
	.then(result => result.find(findJohnDoe))
	.then(customer => instance.customers.getAddresses(customer.id))
	.then(deleteAllAddressesOfCustomer)
	.then(() => console.log('Successfully deleted addresses'))
	.catch(console.error)

More usage

To see all available API methods please refer to the API documentation.

Contributing

Getting started

To get started you may read the contribution document.

Pull requests are always welcome.

Security vulnerabilities

If you encounter any security vulnerabilities, please contact @rx2x (project creator) in place of creating an issue.

License

MIT

node-gambio-api-client's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.