1 min read

SDK SFCC

SDK Based on OCAPI v21.9. Resources to check:

  • Detailed information about request/response params, can be found here: OCAPI Reference.
  • Additional reference with description of mid-level service, contracts and clients can be found here: SDK API Reference.

Installation

npm install @poq/sdk-sfcc

Description

Package provides OCAPI Clients, Contracts and Mid-Level service to convert OCAPI objects into the Poq Contracts.

Supported Mid-Level Services

ServiceDescriptionAPI Reference
AccountServiceService covers account specific operations such as user registration,login, logout, guest token generation and so.More Details
CartServiceService aims to provide an abstraction over Sfcc Basket operations and handles guest baskets alongside with.More Details
CartTransferServiceService helps to transfer items from cart transfer request to sfcc basket.More Details
CheckoutServiceService helps to initiate checkout start procedure.More Details
SearchServiceService aims to provide an abstraction over Sfcc Product search operations.More Details

Getting started

Information about Client as mentioned above can be found there: Client Reference.

Code-guide how to match method and API path to work with:

import {
BasketsClient,
CategoriesClient,
Configuration,
ContentClient,
ContentSearchClient,
CustomersClient,
CustomObjectsClient,
FoldersClient,
GiftCertificateClient,
OrdersClient,
OrderSearchClient,
PriceAdjustmentLimitsClient,
ProductListsClient,
ProductsClient,
ProductSearchClient,
PromotionsClient,
SearchSuggestionClient,
SessionsClient,
SiteClient,
StoresClient
} from '@poq/sdk-sfcc';
/**
* basePath - Base path to your sfcc server.
*/
const configuration = new Configuration({
basePath: 'https://base_path_to_your_api',
username: 'your_user', // optional
password: 'your_pass', // optional
accessToken: 'your_access_token', // optional
apiKey: 'your_api_key', // optional
locale: 'en-US', // optional
currency: 'GBP' // optional
});

Resource: Basket Client

import { Basket, BasketsClient } from '@poq/sdk-sfcc';
const basketClient = new BasketsClient(configuration);
let basketData: Basket;
// ... basket data is inited here
basketClient.postBaskets(basketData);
// Methods anatomy
// Given endpoint from documentation:
// POST `/baskets` - Creates a new basket.
// First goes http method name then endpoint part.
basketClient.postBaskets(basketData);
// More complext examples.
// Pay attention to correspondance in api methods and http verbs + endpoint parts.
// POST `/baskets/{basket_id}/shipments` - Creates a new shipment for a basket.
basketClient.postBasketsByIDShipments('basket_id', shipmentData);
// DELETE `/baskets/{basket_id}/gift_certificate_items/{gift_certificate_item_id}` - Deletes a gift certificate item from an existing basket.
basketClient.deleteBasketsByIDGiftCertificateItemsByID(
'basket_id',
'gift_cert_item_id'
);

Resource: Category Client

const categoriesClient = new CategoriesClient(configuration);

Resource: Content Client

const contentapi = new ContentClient(configuration);

Resource: Content Search Client

const contentSearchClient = new ContentSearchClient(configuration);

Resource: Customers Client

const customersClient = new CustomersClient(configuration);

Resource: Custom Objects Client

const customObjectsClient = new CustomObjectsClient(configuration);

Resource: Folders Client

const foldersClient = new FoldersClient(configuration);

Resource: Gift Certificate Client

const giftCertificateClient = new GiftCertificateClient(configuration);

Resource: Orders Client

const ordersClient = new OrdersClient(configuration);

Resource: Order Search Client

const orderSearchClient = new OrderSearchClient(configuration);

Resource: Price Adjustment Limits Client

const priceAdjustmentLimitsClient = new PriceAdjustmentLimitsClient(
configuration
);

Resource: Product Lists Client

const productListsClient = new ProductListsClient(configuration);

Resource: Products Client

const productsClient = new ProductsClient(configuration);

Resource: Product Search Client

const productSearchClient = new ProductSearchClient(configuration);

Resource: Promotions Client

const promotionsClient = new PromotionsClient(configuration);

Resource: Search Suggestion Client

const searchSuggestionClient = new SearchSuggestionClient(configuration);

Resource: Sessions Client

const sessionsClient = new SessionsClient(configuration);

Resource: Site Client

const siteClient = new SiteClient(configuration);

Resource: Stores Client

const storesClient = new StoresClient(configuration);