Skip to main content

Client

The Client class is the main entry point for interacting with PromoStandards services. It manages authentication credentials, service endpoints, and provides methods for making API requests.

Constructor

Create a new PromoStandards Client instance.
import { PromoStandards } from 'promostandards';

const client = new PromoStandards.Client({
  id: 'your-username',
  password: 'your-password',
  endpoints: [
    {
      type: 'ProductData',
      version: '1.0.0',
      url: 'https://api.supplier.com/ProductData'
    }
  ],
  format: 'json'
});

Parameters

options
object
Configuration options for the client
id
string
Username provided by the supplier for authentication
password
string
Password provided by the supplier for authentication
endpoints
ServiceEndpointType[]
Array of service endpoint configurations. See ServiceEndpointType for details.
format
ResponseFormatType
default:"json"
Response format type. Can be "json" or "xml". Defaults to "json".

Properties

id
string
The username used for authentication with PromoStandards services
password
string
The password used for authentication with PromoStandards services
endpoints
ServiceEndpointType[]
Array of configured service endpoints
format
ResponseFormatType
The response format for API calls. Either "json" or "xml"

Methods

getEndpoint()

Retrieves a specific service endpoint configuration.
const endpoint = client.getEndpoint('ProductData');
console.log(endpoint);
// { type: 'ProductData', version: '1.0.0', url: 'https://...' }
serviceName
ServiceType
required
The name of the service endpoint to retrieve. See ServiceType for valid values.
Returns: ServiceEndpointType Throws: ReferenceError if the specified service endpoint is not configured

promoStandardsAPIRequest()

Generic method for making PromoStandards API requests. This is the underlying method used by all service namespaces.
const response = await client.promoStandardsAPIRequest(
  'ProductData.getProduct',
  {
    productId: 'ABC123',
    localizationCountry: 'US',
    localizationLanguage: 'en'
  }
);
serviceAndMethodName
string
required
Service and method name in the format "ServiceName.methodName" (e.g., "ProductData.getProduct")
params
any
required
Parameters required for the specified PromoStandards method
Returns: Promise<any> - Resolves with the API response in the format specified by the format property

Service Namespaces

The Client provides convenient namespaced methods for each PromoStandards service. Each method is a wrapper around promoStandardsAPIRequest().

productData

Methods for accessing product information.
const product = await client.productData.getProduct({
  productId: 'ABC123',
  localizationCountry: 'US',
  localizationLanguage: 'en'
});
getProduct
function
Get detailed product information
getProductSellable
function
Get sellable product information
getProductDateModified
function
Get products modified after a specific date
getProductCloseOut
function
Get close-out product information

mediaContent

Methods for accessing product media and images.
const media = await client.mediaContent.getMediaContent({
  productId: 'ABC123'
});
getMediaContent
function
Get media content for a product
getMediaDateModified
function
Get media content modified after a specific date

inventory

Methods for checking product inventory and availability.
const levels = await client.inventory.getInventoryLevels({
  productId: 'ABC123'
});
getInventoryLevels
function
Get current inventory levels for products
getFilterValues
function
Get available filter values for inventory queries

orderStatus

Methods for retrieving order status information.
const status = await client.orderStatus.getOrderStatusDetails({
  purchaseOrderNumber: 'PO-12345'
});
getOrderStatusDetails
function
Get detailed status information for an order
getOrderStatusTypes
function
Get available order status types

orderShipmentNotification

Methods for retrieving shipment notifications.
const notification = await client.orderShipmentNotification.getOrderShipmentNotification({
  purchaseOrderNumber: 'PO-12345'
});
getOrderShipmentNotification
function
Get shipment notification details for an order

invoice

Methods for retrieving invoice information.
const invoices = await client.invoice.getInvoices({
  purchaseOrderNumber: 'PO-12345'
});
getInvoices
function
Get invoice information for orders

productPricingAndConfiguration

Methods for product pricing and configuration options.
const locations = await client.productPricingAndConfiguration.getAvailableLocations({
  productId: 'ABC123'
});
getAvailableLocations
function
Get available decoration locations for a product
getDecorationColors
function
Get available decoration colors
getFobPoints
function
Get FOB (Freight on Board) points
getAvailableCharges
function
Get available charges for product configuration
getConfigurationAndPricing
function
Get complete configuration and pricing information

purchaseOrder

Methods for submitting purchase orders.
const result = await client.purchaseOrder.sendPO({
  purchaseOrderNumber: 'PO-12345',
  // ... other order details
});
sendPO
function
Submit a purchase order to the supplier

Example Usage

Here’s a complete example showing how to create a client and make requests:
import { PromoStandards } from 'promostandards';

// Initialize the client
const client = new PromoStandards.Client({
  id: 'supplier-username',
  password: 'supplier-password',
  endpoints: [
    {
      type: 'ProductData',
      version: '1.0.0',
      url: 'https://api.supplier.com/ProductData'
    },
    {
      type: 'Inventory',
      version: '1.2.1',
      url: 'https://api.supplier.com/Inventory'
    }
  ],
  format: 'json'
});

// Get product information
const product = await client.productData.getProduct({
  productId: 'ABC123',
  localizationCountry: 'US',
  localizationLanguage: 'en'
});

// Check inventory levels
const inventory = await client.inventory.getInventoryLevels({
  productId: 'ABC123'
});

console.log('Product:', product);
console.log('Inventory:', inventory);

Build docs developers (and LLMs) love