
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@e2y/occ-client
Advanced tools
occ-client
This package acts as a client for the SAP commerce OCC Rest API Version: 2.0.
import { OccClient, OAuthClient, OauthClientConfig } from '@e2y/occ-client';
void (async () => {
const oauthUrl = 'https://localhost:9002/authorizationserver/oauth/';
const occUrl = 'https://localhost:9002/occ/v2/';
const oauthClientConfig: OauthClientConfig = {
client_id: 'clientId',
client_secret: '******',
grant_type: 'client_credentials',
scope: 'extended'
};
const oauth = new OAuthClient(oauthUrl, oauthClientConfig);
const { access_token: accessToken } = await oauth.clientCredentials();
const occ = new OccClient(occUrl, { accessToken });
const user = await occ.users.registersACustomer('electronics', {
uid: 'fernando.alonso@e2ycommerce.com',
firstName: 'Fernando',
lastName: 'Alonso',
password: '******'
});
})();
Depending on project needs, could be necessary to implement custom occ endpoints. To interact with them through the occ client, we would need to create a custom occ client that extends it using the new endpoints.
// mirakl-extended-cart.ts
import { Cart, HttpClient, OccConfig } from '@e2y/occ-client';
import axios from 'axios';
export class MiraklExtendedCarts extends HttpClient {
constructor(baseURL: string, { accessToken }: OccConfig) {
super({
baseURL,
headers: {
Authorization: `Bearer ${accessToken}`
}
});
}
async getCartWithMarketplaceDeliveryOptions(baseSiteId: string, cartId: string, userId = 'anonymous'): Promise<Cart> {
const url = `/${baseSiteId}/users/${userId}/carts/${cartId}/marketplacedeliverymodes`;
try {
const { data } = await this.client.get<Cart>(url);
return data;
} catch (error) {
if (axios.isAxiosError(error)) {
console.error(error.toJSON(), error.response?.data);
}
throw new Error(`Ops! something went wrong`);
}
}
}
// custom-occ-client.ts
import { OccClient, OccConfig } from '@e2y/occ-client';
import { MiraklExtendedCarts } from './mirakl-extended-cart';
export class CustomOccClient extends OccClient {
public readonly miraklExtendedCarts: MiraklExtendedCarts;
constructor(baseURL: string, config: OccConfig) {
super(baseURL, config);
this.miraklExtendedCarts = new MiraklExtendedCarts(baseURL, config);
}
}
// index.ts
const occ = new OccClient(occUrl, { accessToken });
const cart = await occ.miraklExtendedCarts.getCartWithMarketplaceDeliveryOptions('electronics', 'abc123');
FAQs
OCC client for SAP Commerce Cloud
The npm package @e2y/occ-client receives a total of 1,597 weekly downloads. As such, @e2y/occ-client popularity was classified as popular.
We found that @e2y/occ-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.