reshuffle-fastspring-connector
v0.0.3
Published
Reshuffle connectors for FastSpring
Downloads
6
Maintainers
Readme
reshuffle-fastspring-connector
Code | npm | Code sample
npm install reshuffle-fastspring-connector
Reshuffle FastSpring Connector
This package contains a Resshufle connector to fastspring.com. It can be used to configure and manage online store and purchases, and privdes access to the full FastSpring API.
This example gets the product list from Fast Spring:
const { Reshuffle } = require('reshuffle')
const { FastSpringConnector } = require('reshuffle-fastspring-connector')
;(async () => {
const app = new Reshuffle()
const fs = new FastSpringConnector(app, {
username: process.env.FASTSPRING_USERNAME,
password: process.env.FASTSPRING_PASSWORD,
})
const products = await fs.getProductList()
console.log(products)
})()
Table of Contents
Configuration Configuration options
Connector actions:
deleteProduct Delete a product
getLocalizedPrice Get price in a specific country
getProductInfo Get product information
getProductList Get a list of available products
updateProduct Create or update one product
updateProducts Create or update multiple products
updateSimpleProduct Simplified create/update action
REST:
DELETE Direct REST DELETE
GET Direct REST GET
POST Direct REST POST
Configuration options
const app = new Reshuffle()
const fastSpringConnector = new FastSpringConnector(app)
Connector actions
Delete Product action
Definition:
(
productID: string,
) => void
Usage:
await fastSpringConnector.deleteProduct('my-product')
Delete a product from the store.
Get Localized Price action
Definition:
(
productID: string,
countryCode?: string, // optional
) => number
Usage:
const usd = await fastSpringConnector.getLocalizedPrice('my-product', 'US')
Get the price for a product in a specific country. If a price in local currency was not defined for the product, then the stored price is automaically converted into local currency.
Get Product Info action
Definition:
(
productID: string,
) => Object
Usage:
const info = await fastSpringConnector.getProductInfo('my-product')
Get the full product information. See updateProduct below for details.
Get Product List action
Definition:
() => string[]
Usage:
const list = await fastSpringConnector.getProductist()
Get a list of product IDs for all the products in your store.
Update Product action
Definition:
(
productID: string,
info: Object,
) => void
Usage:
await fastSpringConnector.updateProduct('my-product', {
display: {
en: 'My Product',
},
pricing: {
price: { USD: 3.14 },
},
})
Create or update a product with a specified ID. A full description of the product information object can be found here.
Update is an additive operation, i.e. fields that are not included in the
info
object are not removed from the object record. Rather new fields are
added and new values for exsiting fields are updated.
If no product with the specified ID exists, then a new object is created.
Update Products action
Definition:
(
info: Object[],
) => void
Usage:
await fastSpringConnector.updateProducts([
{ product: 'p1', display: { en: 'Product One' } },
{ product: 'p2', display: { en: 'Product Two' } },
])
Create or update multiple products using product info objects. A full description of the product information object can be found here.
Update Simple Product action
Definition:
(
productID: string,
englishDisplay: string, // display name
usd: number, // price in USD
) => void
Usage:
await fastSpringConnector.updateProduct('my-product', 'My Product', 3.14)
A simplified interface for creating or updating product information. For full control over product info, use updateSimpleProduct above.
REST
DELETE action
Definition:
(
path: string,
) => object | text
Usage:
const response = await fastSpringConnector.DELETE(`products/${id}`)
Send a DELETE request. Returns a JavaScript object for JSON responses or text string otherwise. Throws an exception if a non-2xx HTTP code is returned.
GET action
Definition:
(
path: string,
) => object | text
Usage:
const response = await fastSpringConnector.GET(`products/${id}`)
Send a GET request. Returns a JavaScript object for JSON responses or text string otherwise. Throws an exception if a non-2xx HTTP code is returned.
POST action
Definition:
(
path: string,
body: object,
) => object | text
Usage:
const response = await fastSpringConnector.POST(
'products',
{ products: productInfo },
)
Send a POST request. Returns a JavaScript object for JSON responses or text string otherwise. Throws an exception if a non-2xx HTTP code is returned.