GithubHelp home page GithubHelp logo

onasusweb / prestashop-api-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itconsultis/prestashop-api-client

0.0 1.0 0.0 148 KB

Javascript PrestaShop API client

License: MIT License

Shell 1.56% Vim Script 0.62% JavaScript 97.82%

prestashop-api-client's Introduction

PrestaShop API Client

This is a server-side library that exposes the PrestaShop web service as resource and model abstractions. It allows web service consumers to be unaware of the web service's HTTP interface, or how to deal with XML payloads.

Basic usage

Create a client instance

import { rest } from 'prestashop-api-client';

const client = new rest.Client({
  language: 'en',
  languages: {
    'en': 1,
    'es': 2,
  },
  webservice: {
    key: 'YOUR_PRESTASHOP_API_KEY',
    scheme: 'https',
    host: 'your-prestashop-domain',
    root: '/api',
  },
});

Change the current client language

client.setLanguageIso('en');

Access a resource

const resource = client.resource('products');

Retrieve all models exposed by a resource

resource.list().then((models) => {
  // models is an Array containing Model instances
});

Retrieve a single model from a resource by its ID

resource.get(id).then((model) => {
  // model is a Model instance
});

Resources

  • products
  • images
  • manufacturers
  • combinations
  • stock_availables
  • product_option_values

Models

  • Product
  • Image
  • Manufacturer
  • Combination
  • StockAvailable
  • ProductOptionValue

Model relations

Some concrete Models implement methods that return a Resource. When a Model returns a Resource this way, that resource acts on objects that are related to that model.

Product

// get an Images resource that exposes Image models related to the Product
product.images()

// get Image models related to the Product
product.images().list()

// get a Manufacturers resource
product.manufacturer()

// get the related Manufacturer model
product.manufacturer().first()

// get a Combinations resource
product.combinations()

// get Combination models related to the Product
product.combinations().list()

Client options

languages

A dictionary that maps ISO-639-1 language codes to PrestaShop language ids.

language

The language to select when parsing translatable attributes.

webservice

HTTP request parameters

key       HTTP Basic Auth username
scheme    defaults to "https"
host      your PrestaShop host
root      the api root path; defaults to "/api"

logger

A logger instance. Defaults to dummy logger that doesn't log anything.

Contributing

  1. Fork develop branch
  2. Push changes to your fork.
  3. Submit a pull request.

License

MIT

prestashop-api-client's People

Contributors

rich-choy avatar

Watchers

James Cloos 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.