Giter VIP home page Giter VIP logo

commercecloud-ocapi-client's Introduction

Salesforce Commerce Cloud OCAPI Client

_______________________________________________________________________________________________________________________________________________________

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

NPM

CircleCI

๐Ÿ™Œ Introduction

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

  • API version: 17.8

โš’ 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/v17_8',
  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/v17_8"
}

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

commercecloud-ocapi-client's People

Contributors

bendvc avatar johnboxall avatar kevinxh avatar olibrook avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.