Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## To be released
- Fix refine option processing to include refine_1 ... refine_n alternatives
- Fix rollup format 'cjs' --> 'es'

## v0.1.0 (November 6, 2017)
- Module name change
- Add ASCII art
Expand Down
26 changes: 26 additions & 0 deletions docs/ApiClient.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,32 @@ <h1 class="page-title">Source: ApiClient.js</h1>
}
}

/**
* Builds an object with refinement keys 1..n given a options object..
* @param {Object} opts Optional parameters
* @returns {Object} An object with refinement keys numbered 1 ... n with their
* string representation value.
*/
buildRefineParams(opts) {
const refinements = Object.keys(opts).filter((key) => /^refine/.test(key))
const queryParams = {}

if (refinements.length > 0) {
const useSuffix = refinements.length > 1

refinements.forEach((key, idx) => {
if (!opts[key]) {
return
}

queryParams[`refine${useSuffix ? `_${idx + 1}` : ''}`] =
this.buildCollectionParam(opts[key], 'csv')
})
}

return queryParams
}

/**
* Applies authentication headers to the request.
* @param {Object} request The request object created by a &lt;code>superagent()&lt;/code> call.
Expand Down
4 changes: 3 additions & 1 deletion docs/api_ContentSearchApi.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ <h1 class="page-title">Source: api/ContentSearchApi.js</h1>
const pathParams = {}
const queryParams = {
q: opts.q,
refine: this.apiClient.buildCollectionParam(opts.refine, 'csv'),
sort: this.apiClient.buildCollectionParam(opts.sort, 'csv'),
start: opts.start,
count: opts.count,
locale: opts.locale
}

Object.assign(queryParams, this.apiClient.buildRefineParams(opts))

const headerParams = {}
const formParams = {}

Expand Down
20 changes: 15 additions & 5 deletions docs/api_ProductSearchApi.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,16 @@ <h1 class="page-title">Source: api/ProductSearchApi.js</h1>
const pathParams = {}
const queryParams = {
q: opts.q,
refine: this.apiClient.buildCollectionParam(opts.refine, 'csv'),
sort: opts.sort,
start: opts.start,
count: opts.count,
expand: this.apiClient.buildCollectionParam(opts.expand, 'csv'),
currency: opts.currency,
locale: opts.locale
}

Object.assign(queryParams, this.apiClient.buildRefineParams(opts))

const headerParams = {}
const formParams = {}

Expand Down Expand Up @@ -183,12 +185,14 @@ <h1 class="page-title">Source: api/ProductSearchApi.js</h1>
const pathParams = {}
const queryParams = {
q: opts.q,
refine: this.apiClient.buildCollectionParam(opts.refine, 'csv'),
sort: opts.sort,
start: opts.start,
count: opts.count,
locale: opts.locale
}

Object.assign(queryParams, this.apiClient.buildRefineParams(opts))

const headerParams = {}
const formParams = {}

Expand Down Expand Up @@ -264,12 +268,14 @@ <h1 class="page-title">Source: api/ProductSearchApi.js</h1>
const pathParams = {}
const queryParams = {
q: opts.q,
refine: this.apiClient.buildCollectionParam(opts.refine, 'csv'),
sort: opts.sort,
start: opts.start,
count: opts.count,
locale: opts.locale
}

Object.assign(queryParams, this.apiClient.buildRefineParams(opts))

const headerParams = {}
const formParams = {}

Expand Down Expand Up @@ -346,13 +352,15 @@ <h1 class="page-title">Source: api/ProductSearchApi.js</h1>
const pathParams = {}
const queryParams = {
q: opts.q,
refine: this.apiClient.buildCollectionParam(opts.refine, 'csv'),
sort: opts.sort,
start: opts.start,
count: opts.count,
currency: opts.currency,
locale: opts.locale
}

Object.assign(queryParams, this.apiClient.buildRefineParams(opts))

const headerParams = {}
const formParams = {}

Expand Down Expand Up @@ -427,12 +435,14 @@ <h1 class="page-title">Source: api/ProductSearchApi.js</h1>
const pathParams = {}
const queryParams = {
q: opts.q,
refine: this.apiClient.buildCollectionParam(opts.refine, 'csv'),
sort: opts.sort,
start: opts.start,
count: opts.count,
locale: opts.locale
}

Object.assign(queryParams, this.apiClient.buildRefineParams(opts))

const headerParams = {}
const formParams = {}

Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h3> </h3>
/
/</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>
<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>
<h2>Introduction</h2><p>ShopApi - JavaScript client for Salesforce Commerce Cloud OCAPI Shop API.</p>
<h2>Introduction</h2><p>ShopApi - ES6 JavaScript client for Salesforce Commerce Cloud OCAPI Shop API.</p>
<ul>
<li>API version: 17.8</li>
</ul>
Expand Down
170 changes: 164 additions & 6 deletions docs/module-ApiClient.html
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line606">line 606</a>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line632">line 632</a>
</li></ul></dd>


Expand Down Expand Up @@ -905,7 +905,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line529">line 529</a>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line555">line 555</a>
</li></ul></dd>


Expand Down Expand Up @@ -1050,7 +1050,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line516">line 516</a>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line542">line 542</a>
</li></ul></dd>


Expand Down Expand Up @@ -1230,7 +1230,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line326">line 326</a>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line352">line 352</a>
</li></ul></dd>


Expand Down Expand Up @@ -1448,6 +1448,164 @@ <h5>Returns:</h5>



<h4 class="name" id="buildRefineParams"><span class="type-signature"></span>buildRefineParams<span class="signature">(opts)</span><span class="type-signature"> &rarr; {Object}</span></h4>






<div class="description">
<p>Builds an object with refinement keys 1..n given a options object..</p>
</div>









<h5>Parameters:</h5>


<table class="params">
<thead>
<tr>

<th>Name</th>


<th>Type</th>





<th class="last">Description</th>
</tr>
</thead>

<tbody>


<tr>

<td class="name"><code>opts</code></td>


<td class="type">


<span class="param-type">Object</span>



</td>





<td class="description last"><p>Optional parameters</p></td>
</tr>


</tbody>
</table>






<dl class="details">


























<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line327">line 327</a>
</li></ul></dd>







</dl>













<h5>Returns:</h5>


<div class="param-desc">
<p>An object with refinement keys numbered 1 ... n with their
string representation value.</p>
</div>



<dl>
<dt>
Type
</dt>
<dd>

<span class="param-type">Object</span>


</dd>
</dl>













<h4 class="name" id="buildUrl"><span class="type-signature"></span>buildUrl<span class="signature">(path, pathParams)</span><span class="type-signature"> &rarr; {String}</span></h4>


Expand Down Expand Up @@ -1967,7 +2125,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line408">line 408</a>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line434">line 434</a>
</li></ul></dd>


Expand Down Expand Up @@ -2159,7 +2317,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line376">line 376</a>
<a href="ApiClient.js.html">ApiClient.js</a>, <a href="ApiClient.js.html#line402">line 402</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/module-api_ContentSearchApi.html
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ <h6>Properties</h6>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="api_ContentSearchApi.js.html">api/ContentSearchApi.js</a>, <a href="api_ContentSearchApi.js.html#line111">line 111</a>
<a href="api_ContentSearchApi.js.html">api/ContentSearchApi.js</a>, <a href="api_ContentSearchApi.js.html#line113">line 113</a>
</li></ul></dd>


Expand Down
Loading