0.3.11 • Published 8 years ago

prestashop-api-client v0.3.11

Weekly downloads
248
License
MIT
Repository
github
Last release
8 years ago

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

0.3.11

8 years ago

0.3.10

8 years ago

0.3.9

8 years ago

0.3.8

8 years ago

0.3.7

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.14

8 years ago

0.2.13

8 years ago

0.2.12

8 years ago

0.2.11

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.10

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago