npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mgara/commercecloud-ocapi-client

v0.2.3

Published

An ES6 JavaScript Client for Salesforce Open Commerce API

Downloads

6

Readme

Salesforce Commerce Cloud OCAPI Client

_______________________________________________________________________________________________________________________________________________________

                                                            /                    /                                 ,             /   ,                 
----__----__---_--_---_--_----__---)__----__----__----__---/----__-----------__-/--------__----__----__------__------------__---/--------__----__--_/_-
  /   ' /   ) / /  ) / /  ) /___) /   ) /   ' /___) /   ' /   /   ) /   /  /   /       /   ) /   ' /   )   /   ) /       /   ' /   /   /___) /   ) /   
_(___ _(___/_/_/__/_/_/__/_(___ _/_____(___ _(___ _(___ _/___(___/_(___(__(___/_______(___/_(___ _(___(___/___/_/_______(___ _/___/___(___ _/___/_(_ __
                                                                                                         /                                             
                                                                                                        /                                              

NPM

CircleCI

🙌 Introduction

Salesforce Commerce Cloud Open Commerce API (OCAPI) for Node and browsers.

  • API version: 20.4

⚒ Installation

This library is distributed on npm, in order to add it as a dependency, run the following command:

npm install commercecloud-ocapi-client --save

🔦 Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

👨🏻‍💻 Getting Started

💡 Usage

Please follow the installation instruction and execute the following JS code:

import ShopApi from 'commercecloud-ocapi-client'

ShopApi.ApiClient.instance = new ShopApi.ApiClient()

const api = new ShopApi.CategoriesApi()

api.getCategoriesByIDs(['mens', 'newarrivals'])
    .then(() {
        console.log('API called successfully.')
    })
    .catch((fault) => {
        console.error(fault)
    })

🔌 Configuration

The API client accepts an configuration object, example:

import ShopApi from 'commercecloud-ocapi-client'

const config = {
  basePath: 'https://localhost/s/siteId/dw/shop/v20_4',
  defaultHeaders: {}, // HTTP header for all requests
  timeout: 60000, // Request timeout in milliseconds
  cache: true, // If set to false an additional timestamp parameter is added to all API GET calls to prevent browser caching
  enableCookies: false, //If set to true, the client will save the cookies from each server response, and return them in the next request.
  overrideHttpPut: true // If set to true, any methods specified as using http PUT will be sent using POST along the header value 'x-dw-http-method-override' set to 'PUT'.
}

ShopApi.ApiClient.instance = new ShopApi.ApiClient(config)

🔐 Authorization

To access secure end points, you can pass the username, password in the configuration, example:

import ShopApi from 'commercecloud-ocapi-client'

const config = {
  clientUsername: 'username',
  clientPassword: 'password',
}

ShopApi.ApiClient.instance = new ShopApi.ApiClient(config)

Or to use oAuth token:

import ShopApi from 'commercecloud-ocapi-client'

const config = {
  oauth2AccessToken: 'token'
}

ShopApi.ApiClient.instance = new ShopApi.ApiClient(config)

✅ Testing

Because Salesforce OCAPI is not publicly available, you need to have a running instance that you can test against. In the test folder, there is a file config.json that has the example configuration for your environment. Simply update the file with your instance information

Example:

{
  "clientId": "5640cc6b-f5e9-466e-9134-9853e9f9db93",
  "baseUrl": "https://localhost/s/siteId/dw/shop/v20_4"
}

Then run the following command:

npm test

♻️ Continuous Integration

We use Circle CI to protect the develop and master branch to make sure the builds follows the code style and passes all tests. For every pull request, it is required to pass ALL checks including the following tests:

  • Linting: npm run lint
  • Unit Tests: npm run test

📦 Build and Deployment

At Mobify, we practice several branching strategies, Release Deployment is a strategy for projects where feature gets bundled into a release periodically. master contains the code for current version, develop has the features that is under development and waiting to be released. For new features and bug fixes, please propose pull requests to merge into develop.

This package is distributed on npm, on every release, we run scripts to automatically merge develop into master, test the build in Circle CI as well as publish the package on NPM.

Changelog

To understand the change between versions, please read CHANGELOG.md. Note that it is required to have a # To be released section filled out if you are planning to make pull requests that include new features or bug fixes.

Example:

## To be released
- Update npm package to ship with three builds: `UMD`, `CommonJS` and `ES2015` [#4](https://github.com/mobify/commercecloud-ocapi-client/pull/4)

## v0.1.1 (November 7, 2017)
- Update Rollup output format to 'es'

...

📖 Documentation

👥 Owner

This project is open sourced and actively maintained by Mobify. We will make an effort to support the library, but we reserve the right to make incompatible changes when necessary.

🏅 Contributors