Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 68a8c5c

Browse files
authored
Merge release-v0.1.4 into master
2 parents 678ff57 + f1e3378 commit 68a8c5c

File tree

5 files changed

+69
-42
lines changed

5 files changed

+69
-42
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v0.1.4 (June 21, 2018)
2+
- Fix superagent `attachCookies` and `saveCookies` usage
3+
14
## v0.1.3 (May 9, 2018)
25
- Ensure we are shipping ES5 everywhere.
36

docs/ApiClient.js.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ <h1 class="page-title">Source: ApiClient.js</h1>
498498
// Attach previously saved cookies, if enabled
499499
if (this.enableCookies) {
500500
if (typeof window === 'undefined') {
501-
this.agent.attachCookies(request)
501+
this.agent._attachCookies(request)
502502
} else {
503503
request.withCredentials()
504504
}
@@ -521,7 +521,7 @@ <h1 class="page-title">Source: ApiClient.js</h1>
521521
try {
522522
const data = this.deserialize(response, returnType)
523523
if (this.enableCookies &amp;&amp; typeof window === 'undefined') {
524-
this.agent.saveCookies(response)
524+
this.agent._saveCookies(response)
525525
}
526526

527527
resolve({

docs/index.html

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,12 @@ <h3> </h3>
5252
/
5353
/</code></pre><p><a href="https://nodei.co/npm/commercecloud-ocapi-client/"><img src="https://nodei.co/npm/commercecloud-ocapi-client.png?downloads=true&amp;stars=true" alt="NPM"></a></p>
5454
<p><a href="https://circleci.com/gh/mobify/commercecloud-ocapi-client"><img src="https://circleci.com/gh/mobify/commercecloud-ocapi-client.svg?style=svg" alt="CircleCI"></a></p>
55-
<h2>Introduction</h2><p>ShopApi - JavaScript client for Salesforce Commerce Cloud OCAPI Shop API.</p>
55+
<h2>🙌 Introduction</h2><p>Salesforce Commerce Cloud Open Commerce API (OCAPI) for Node and browsers.</p>
5656
<ul>
5757
<li>API version: 17.8</li>
5858
</ul>
59-
<h2>Installation</h2><h3>For <a href="https://nodejs.org/">Node.js</a></h3><h4>npm</h4><p>To publish the library as a <a href="https://www.npmjs.com/">npm</a>,
60-
please follow the procedure in <a href="https://docs.npmjs.com/getting-started/publishing-npm-packages">&quot;Publishing npm packages&quot;</a>.</p>
61-
<p>Then install it via:</p>
62-
<pre class="prettyprint source lang-shell"><code>npm install commercecloud-ocapi-client --save</code></pre><h4>git</h4><p>#
63-
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-
<pre class="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 <a href="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-
<pre class="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: &quot;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+
<pre class="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: &quot;Module not found: Error:
7161
Cannot resolve module&quot;, most certainly you should disable AMD loader. Add/merge
7262
the following section to your webpack config:</p>
7363
<pre class="prettyprint source lang-javascript"><code>module: {
@@ -78,41 +68,75 @@ <h3>Webpack Configuration</h3><p>Using Webpack you may encounter the following e
7868
}
7969
}
8070
]
81-
}</code></pre><h2>Getting Started</h2><p>Please follow the <a href="#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 <a href="#installation">installation</a> instruction and execute the following JS code:</p>
8272
<pre class="prettyprint source lang-javascript"><code>import ShopApi from 'commercecloud-ocapi-client'
8373

84-
ShopApi.ApiClient.instance = new ShopApi.ApiClient({
85-
clientUsername: 'YOUR USERNAME', // Configure HTTP basic authorization: customers_auth
86-
clientPassword: 'YOUR PASSWORD', // Configure HTTP basic authorization: customers_auth
87-
oAuthAccessToken: '' // Configure OAuth2 access token for authorization: oauth2_application
88-
})
74+
ShopApi.ApiClient.instance = new ShopApi.ApiClient()
8975

90-
const api = new ShopApi.BasketsApi()
76+
const api = new ShopApi.CategoriesApi()
9177

92-
const basketId = &quot;basketId_example&quot; // {String} the id of the basket to be retrieved
93-
94-
api.deleteBasketsByID(basketId)
78+
api.getCategoriesByIDs(['mens', 'newarrivals'])
9579
.then(() {
9680
console.log('API called successfully.')
9781
})
9882
.catch((fault) => {
9983
console.error(fault)
100-
})</code></pre><h2>Documentation for API Endpoints</h2><ul>
101-
<li><a href="https://mobify.github.io/commercecloud-ocapi-client/">API Docs</a></li>
102-
</ul>
103-
<h2>Documentation for Authorization</h2><h3>client_id</h3><ul>
104-
<li><strong>Type</strong>: API key</li>
105-
<li><strong>API key parameter name</strong>: x-dw-client-id</li>
106-
<li><strong>Location</strong>: HTTP header</li>
84+
})</code></pre><h3>🔌 Configuration</h3><p>The API client accepts an configuration object, example:</p>
85+
<pre class="prettyprint source lang-js"><code>import ShopApi from 'commercecloud-ocapi-client'
86+
87+
const config = {
88+
basePath: 'https://localhost/s/siteId/dw/shop/v17_8',
89+
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+
<pre class="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+
<pre class="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>
111+
<p>Example: </p>
112+
<pre class="prettyprint source lang-json"><code>{
113+
&quot;clientId&quot;: &quot;5640cc6b-f5e9-466e-9134-9853e9f9db93&quot;,
114+
&quot;baseUrl&quot;: &quot;https://localhost/s/siteId/dw/shop/v17_8&quot;
115+
}</code></pre><p>Then run the following command:</p>
116+
<pre class="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>
117+
<ul>
118+
<li>Linting: <code>npm run lint</code></li>
119+
<li>Unit Tests: <code>npm run test</code></li>
107120
</ul>
108-
<h3>customers_auth</h3><ul>
109-
<li><strong>Type</strong>: HTTP basic authentication</li>
121+
<h2>📦 Build and Deployment</h2><p>At Mobify, we practice several branching strategies, <a href="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 <a href="./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+
<pre class="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)
127+
128+
## v0.1.1 (November 7, 2017)
129+
- Update Rollup output format to 'es'
130+
131+
...</code></pre><h2>📖 Documentation</h2><ul>
132+
<li><a href="https://mobify.github.io/commercecloud-ocapi-client/">API Docs</a></li>
110133
</ul>
111-
<h3>oauth2_application</h3><ul>
112-
<li><strong>Type</strong>: OAuth</li>
113-
<li><strong>Flow</strong>: application</li>
114-
<li><strong>Authorization URL</strong>:</li>
115-
<li><strong>Scopes</strong>: N/A</li>
134+
<h2>👥 Owner</h2><p>This project is open sourced and actively maintained by <a href="https://github.com/mobify">Mobify</a>.
135+
We will make an effort to support the library, but we reserve the right to make incompatible changes when necessary.</p>
136+
<h2>🏅 Contributors</h2><ul>
137+
<li><a href="https://github.com/jeremywiebe">@jeremywiebe</a></li>
138+
<li><a href="https://github.com/bendvc">@bendvc</a></li>
139+
<li><a href="https://github.com/kevinxh">@kevinxh</a></li>
116140
</ul></article>
117141
</section>
118142

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "commercecloud-ocapi-client",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "An ES6 JavaScript Client for Salesforce Open Commerce API",
55
"license": "SEE LICENSE IN LICENSE",
66
"main": "dist/commercecloud-ocapi-client.cjs.js",

src/ApiClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ export default class ApiClient {
470470
// Attach previously saved cookies, if enabled
471471
if (this.enableCookies) {
472472
if (typeof window === 'undefined') {
473-
this.agent.attachCookies(request)
473+
this.agent._attachCookies(request)
474474
} else {
475475
request.withCredentials()
476476
}
@@ -493,7 +493,7 @@ export default class ApiClient {
493493
try {
494494
const data = this.deserialize(response, returnType)
495495
if (this.enableCookies && typeof window === 'undefined') {
496-
this.agent.saveCookies(response)
496+
this.agent._saveCookies(response)
497497
}
498498

499499
resolve({

0 commit comments

Comments
 (0)