1.0.7 • Published 2 years ago

@novo-x/prestashop v1.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Prestashop Service

Available methods

  • getCart: retireves a cart
  • getResourceByKey: retrieves a resource by comparing a specific field
  • getResourceById: retrieves a resource by id
  • getResourcesBySchema: retrieves a all resources from a schema
  • updateResource: updates a resource
  • createNew: creates a new resource
  • createCustomer: creates a customer
  • createAddressForCustomer: creates an address and links it to an existent customer
  • createOrUpdateCart: if exists, updates the cart, and if it doesn't exists, creates the cart
  • getProductsDataFromOrder: retrieves a list of products from an order
  • getCouponData: retrieves the applied coupons of an order

Usage examples

yarn add @novo-x/prestashop

import {Prestashop} from "@novo-x/prestashop"

const MyService = new Prestashop(
    '123456789', // apiKey
    'https://mystore.com' // storeUrl
);

const existentCart = await MyService.getCart(
    '123456789' // cartId
);

const resourceByKey = await MyService.getResourceByKey(
    'countries', // schema
    'iso_code', // key
    'es', // value
     false // if true, returns the full array, if false, returns the first one
);

const resourceById = await MyService.getResourceById(
    'products', // schema
    '123456789', // id
);

const resourcesBySchema = await MyService.getResourcesBySchema(
    'carriers', // schema
);

const updatedResource = await MyService.updateResource(
    'customers', // schema 
    '<?xml version="1.0" encoding="UTF-8" ?>'+
    '<root>' +
        '<id>123456789</id>' +
        '<name>John Doe</name>' +
        '...' +
    '</root>', // xmlContent
    '123456789' // resourceId
)

const createdResource = await MyService.createNew(
    'customers', // schema 
    '<?xml version="1.0" encoding="UTF-8" ?>'+
    '<root>' +
        '<id>123456789</id>' +
        '<name>John Doe</name>' +
        '...' +
    '</root>', // xmlContent
)

const customer = await MyService.createCustomer({
    password: 'password123',
    lastName: 'Doe',
    firstName: 'John',
    email: 'john@doe.com',
    isActive: 1
})

const address = await MyService.createAddressForCustomer(
    {
        address1: 'Some address',
        address2: 'Piso 2',
        city: 'City',
        postcode: '46002',
        countryIsoCode: 'ES'
    }, // addressData
    {
        id: '123456789',
        alias: 'myalias',
        lastName: 'Doe',
        firstName: John,
        phone: '+34627190822',
        dni: '123456789',
    } // customerData
);

const cart = await createOrUpdateCart(
    {
        cartId: '123456789',
        product: {
            id: '123456789',
            variantId: '123456789',
            customizationId: '123456789',
            quantity: 3
        }, // productData
        currency: 'EUR'
    }, // orderData
    {
        id: '123456789',
        id_lang: '123456789'
    }, // customerData
    {
        id: 'getProductsDataFromOrder'
    } // addressData
)

const products = MyService.getProductsDataFromOrder(
    '123456789' // orderId
)

const appliedCoupionse = MyService.getCouponData(
    '123456789' // orderId
)

Dependencies

axios

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago