You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
<h2>🙌 Introduction</h2><p>Salesforce Commerce Cloud Open Commerce API (OCAPI) for Node and browsers.</p>
56
56
<ul>
57
57
<li>API version: 17.8</li>
58
58
</ul>
59
-
<h2>Installation</h2><h3>For <ahref="https://nodejs.org/">Node.js</a></h3><h4>npm</h4><p>To publish the library as a <ahref="https://www.npmjs.com/">npm</a>,
60
-
please follow the procedure in <ahref="https://docs.npmjs.com/getting-started/publishing-npm-packages">"Publishing npm packages"</a>.</p>
If the library is hosted at a git repository, e.g.
64
-
https://github.com/GIT_USER_ID/GIT_REPO_ID
65
-
then install it via:</p>
66
-
<preclass="prettyprint source lang-shell"><code> npm install GIT_USER_ID/GIT_REPO_ID --save</code></pre><h3>For browser</h3><p>The library also works in the browser environment via npm and <ahref="http://browserify.org/">browserify</a>. After following
67
-
the above steps with Node.js and installing browserify with <code>npm install -g browserify</code>,
68
-
perform the following (assuming <em>main.js</em> is your entry file):</p>
69
-
<preclass="prettyprint source lang-shell"><code>browserify main.js > bundle.js</code></pre><p>Then include <em>bundle.js</em> in the HTML pages.</p>
70
-
<h3>Webpack Configuration</h3><p>Using Webpack you may encounter the following error: "Module not found: Error:
59
+
<h3>⚒ Installation</h3><p>This library is distributed on npm, in order to add it as a dependency, run the following command:</p>
60
+
<preclass="prettyprint source lang-shell"><code>npm install commercecloud-ocapi-client --save</code></pre><h3>🔦 Webpack Configuration</h3><p>Using Webpack you may encounter the following error: "Module not found: Error:
71
61
Cannot resolve module", most certainly you should disable AMD loader. Add/merge
@@ -78,41 +68,75 @@ <h3>Webpack Configuration</h3><p>Using Webpack you may encounter the following e
78
68
}
79
69
}
80
70
]
81
-
}</code></pre><h2>Getting Started</h2><p>Please follow the <ahref="#installation">installation</a> instruction and execute the following JS code:</p>
71
+
}</code></pre><h2>👨🏻💻 Getting Started</h2><h3>💡 Usage</h3><p>Please follow the <ahref="#installation">installation</a> instruction and execute the following JS code:</p>
82
72
<preclass="prettyprint source lang-javascript"><code>import ShopApi from 'commercecloud-ocapi-client'
83
73
84
-
ShopApi.ApiClient.instance = new ShopApi.ApiClient({
defaultHeaders: {}, // HTTP header for all requests
90
+
timeout: 60000, // Request timeout in milliseconds
91
+
cache: true, // If set to false an additional timestamp parameter is added to all API GET calls to prevent browser caching
92
+
enableCookies: false, //If set to true, the client will save the cookies from each server response, and return them in the next request.
93
+
}
94
+
95
+
ShopApi.ApiClient.instance = new ShopApi.ApiClient(config)</code></pre><h3>🔐 Authorization</h3><p>To access secure end points, you can pass the username, password in the configuration, example:</p>
96
+
<preclass="prettyprint source lang-js"><code>import ShopApi from 'commercecloud-ocapi-client'
97
+
98
+
const config = {
99
+
clientUsername: 'username',
100
+
clientPassword: 'password',
101
+
}
102
+
103
+
ShopApi.ApiClient.instance = new ShopApi.ApiClient(config)</code></pre><p>Or to use oAuth token:</p>
104
+
<preclass="prettyprint source lang-js"><code>import ShopApi from 'commercecloud-ocapi-client'
105
+
106
+
const config = {
107
+
oauth2AccessToken: 'token'
108
+
}
109
+
110
+
ShopApi.ApiClient.instance = new ShopApi.ApiClient(config)</code></pre><h2>✅ Testing</h2><p>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 <code>config.json</code> that has the example configuration for your environment. Simply update the file with your instance information</p>
}</code></pre><p>Then run the following command:</p>
116
+
<preclass="prettyprint source lang-sh"><code>npm test</code></pre><h3>♻️ Continuous Integration</h3><p>We use Circle CI to protect the <code>develop</code> and <code>master</code> 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:</p>
<h2>📦 Build and Deployment</h2><p>At Mobify, we practice several branching strategies, <ahref="https://github.com/mobify/branching-strategy/blob/master/release-deployment.md">Release Deployment</a> is a strategy for projects where feature gets bundled into a release periodically. <code>master</code> contains the code for current version, <code>develop</code> 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 <code>develop</code>.</p>
122
+
<p>This package is distributed on npm, on every release, we run scripts to automatically merge <code>develop</code> into <code>master</code>, test the build in Circle CI as well as publish the package on NPM.</p>
123
+
<h3>Changelog</h3><p>To understand the change between versions, please read <ahref="./CHANGELOG.md">CHANGELOG.md</a>. Note that it is required to have a <code># To be released</code> section filled out if you are planning to make pull requests that include new features or bug fixes.</p>
124
+
<p>Example:</p>
125
+
<preclass="prettyprint source lang-markdown"><code>## To be released
126
+
- Update npm package to ship with three builds: `UMD`, `CommonJS` and `ES2015` [#4](https://github.com/mobify/commercecloud-ocapi-client/pull/4)
0 commit comments