Skip to content

Commit bfedc36

Browse files
authored
Merge pull request #40 from FoxComm/feature/faster-cross-sell
Add crossSellRelatedFull endpoint
2 parents 8f2e1b2 + 1e1e35b commit bfedc36

File tree

4 files changed

+111
-4
lines changed

4 files changed

+111
-4
lines changed

index.html

+49-3
Original file line numberDiff line numberDiff line change
@@ -1830,14 +1830,18 @@ <h3 id='cart-method'>Methods</h3>
18301830
<tr id='cart-addgiftcard'>
18311831
<td><code><b>addGiftCard</b>(<nobr>&lt;<a href='#giftcardpaymentpayload'>GiftCardPaymentPayload</a>&gt;</nobr> <i>giftCardPayload</i>)</nobr></code></td>
18321832
<td><code>Promise&lt;<a href='#fullorder'>FullOrder</a>&gt;</code></td>
1833-
<td>Adds a gift card as payment method for the cart.
1834-
<p>Creates payment method with a given amount using store credit.</p></td>
1833+
<td>Adds a gift card as payment method for the cart.</td>
18351834
</tr>
18361835
<tr id='cart-removegiftcard'>
18371836
<td><code><b>removeGiftCard</b>(<nobr>&lt;string&gt;</nobr> <i>giftCardCode</i>)</nobr></code></td>
18381837
<td><code>Promise&lt;<a href='#fullorder'>FullOrder</a>&gt;</code></td>
18391838
<td>Removes gift card with provided code payment method from the cart.</td>
18401839
</tr>
1840+
<tr id='cart-addstorecredit'>
1841+
<td><code><b>addStoreCredit</b>(<nobr>&lt;Number&gt;</nobr> <i>amount</i>)</nobr></code></td>
1842+
<td><code>Promise&lt;<a href='#fullorder'>FullOrder</a>&gt;</code></td>
1843+
<td>Adds store credit of specified amount to the cart.</td>
1844+
</tr>
18411845
<tr id='cart-removestorecredits'>
18421846
<td><code><b>removeStoreCredits</b>()</nobr></code></td>
18431847
<td><code>Promise&lt;<a href='#fullorder'>FullOrder</a>&gt;</code></td>
@@ -3246,7 +3250,8 @@ <h3 id='crosssell-example'>Usage example</h3>
32463250
]
32473251
}
32483252
</code></pre>
3249-
<p>/v1/public/recommend/prod-prod/3?channel=2</p>
3253+
<p>/v1/public/recommend/prod-prod/3?channel=2
3254+
/v1/public/recommend/prod-prod/3?channel=2</p>
32503255

32513256
<pre><code>{
32523257
&quot;products&quot;: [
@@ -3264,6 +3269,39 @@ <h3 id='crosssell-example'>Usage example</h3>
32643269
}
32653270
]
32663271
}
3272+
</code></pre><pre><code>{
3273+
&quot;products&quot;: [
3274+
{
3275+
&quot;product&quot;: {
3276+
&quot;id&quot;: 300,
3277+
&quot;productId&quot;: 60727,
3278+
&quot;scope&quot;: &quot;1&quot;,
3279+
&quot;albums&quot;: [ { &quot;images&quot;: [...], &quot;name&quot;: &quot;default&quot; } ],
3280+
&quot;context&quot;: &quot;default&quot;,
3281+
&quot;currency&quot;: &quot;USD&quot;,
3282+
&quot;description&quot;: &quot;...&quot;,
3283+
&quot;retailPrice&quot;: &quot;8500&quot;,
3284+
&quot;salePrice&quot;: &quot;8500&quot;,
3285+
&quot;skus&quot;: [ &quot;AB9403_310&quot;, &quot;AB9403_330&quot;, &quot;AB9403_350&quot;, &quot;AB9403_370&quot; ],
3286+
&quot;slug&quot;: &quot;dynamo-away-replica-jersey&quot;,
3287+
&quot;tags&quot;: [ &quot;Apparel&quot;, &quot;Soccer&quot; ],
3288+
&quot;taxonomies&quot;: [
3289+
{ &quot;taxonomy&quot;: &quot;brand&quot;, &quot;taxons&quot;: [ [ &quot;Performance&quot; ] ] },
3290+
{ &quot;taxonomy&quot;: &quot;category&quot;, &quot;taxons&quot;: [ [ &quot;Apparel&quot; ] ] },
3291+
{ &quot;taxonomy&quot;: &quot;color&quot;, &quot;taxons&quot;: [ [ &quot;Black&quot; ], [ &quot;Light Orange&quot; ] ] },
3292+
],
3293+
&quot;title&quot;: &quot;Dynamo Away Replica Jersey&quot;
3294+
},
3295+
&quot;score&quot;: 0.129*9944487358058
3296+
},
3297+
{
3298+
&quot;product&quot;: {
3299+
...
3300+
},
3301+
&quot;score&quot;: 0.07715167498104597
3302+
}
3303+
]
3304+
}
32673305
</code></pre>
32683306

32693307

@@ -3300,6 +3338,14 @@ <h3 id='crosssell-method'>Methods</h3>
33003338
<td>Returns JSON of what products are similar to the productId in the query params.
33013339
{ &quot;products&quot;: [ RelatedProduct ] }
33023340
Score == 1 means these products were purchased by the exact same set of customers.
3341+
Score == 0 means no customer has purchased both of these</td>
3342+
</tr>
3343+
<tr id='crosssell-crosssellrelatedfull'>
3344+
<td><code><b>crossSellRelatedFull</b>(<nobr>&lt;Int&gt;</nobr> <i>productId</i>, <nobr>&lt;Int&gt;</nobr> <i>channelId</i>, <nobr>&lt;Int&gt;</nobr> <i>size</i>, <i>{Int} productId</i>, <i>{Int} channelId</i>, <i>{Int} size</i>)</nobr></code></td>
3345+
<td><code>Promise</code></td>
3346+
<td>Returns JSON of what products are similar to the productId in the query params.
3347+
{ &quot;products&quot;: [ RelatedProductFull ] }
3348+
Score == 1 means these products were purchased by the exact same set of customers.
33033349
Score == 0 means no customer has purchased both of these</td>
33043350
</tr>
33053351
</tbody></table>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@foxcomm/api-js",
3-
"version": "1.1.6",
3+
"version": "1.1.7",
44
"description": "Javascript Library for interacting with FoxCommerce API",
55
"main": "lib/index.js",
66
"publishConfig": {

src/api/cross-sell.js

+60
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,66 @@ export default class CrossSell {
7878
const url = `${endpoints.crossSellRelated}${productId}${query}`;
7979
return this.api.get(url);
8080
}
81+
82+
/**
83+
* @method crossSellRelatedFull(productId: Int, channelId: Int, size: Int): Promise
84+
* @param {Int} productId
85+
* @param {Int} channelId
86+
* @param {Int} size
87+
*
88+
* Returns JSON of what products are similar to the productId in the query params.
89+
* { "products": [ RelatedProductFull ] }
90+
*
91+
* Score == 1 means these products were purchased by the exact same set of customers.
92+
* Score == 0 means no customer has purchased both of these
93+
*
94+
* @example Request
95+
*
96+
* /v1/public/recommend/prod-prod/3?channel=2
97+
*
98+
* @example Response
99+
*
100+
* ```
101+
* {
102+
* "products": [
103+
* {
104+
* "product": {
105+
* "id": 300,
106+
* "productId": 60727,
107+
* "scope": "1",
108+
* "albums": [ { "images": [...], "name": "default" } ],
109+
* "context": "default",
110+
* "currency": "USD",
111+
* "description": "...",
112+
* "retailPrice": "8500",
113+
* "salePrice": "8500",
114+
* "skus": [ "AB9403_310", "AB9403_330", "AB9403_350", "AB9403_370" ],
115+
* "slug": "dynamo-away-replica-jersey",
116+
* "tags": [ "Apparel", "Soccer" ],
117+
* "taxonomies": [
118+
* { "taxonomy": "brand", "taxons": [ [ "Performance" ] ] },
119+
* { "taxonomy": "category", "taxons": [ [ "Apparel" ] ] },
120+
* { "taxonomy": "color", "taxons": [ [ "Black" ], [ "Light Orange" ] ] },
121+
* ],
122+
* "title": "Dynamo Away Replica Jersey"
123+
* },
124+
* "score": 0.129*9944487358058
125+
* },
126+
* {
127+
* "product": {
128+
* ...
129+
* },
130+
* "score": 0.07715167498104597
131+
* }
132+
* ]
133+
*}
134+
* ```
135+
*/
136+
crossSellRelatedFull(productId, channelId, size) {
137+
const query = `?channel=${channelId}&size=${size}`;
138+
const url = `${endpoints.crossSellRelatedFull}${productId}${query}`;
139+
return this.api.get(url);
140+
}
81141
}
82142

83143
// @miniclass Point (CrossSell)

src/endpoints.js

+1
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ export const hal = '/v1/hal';
6161
// cross-sell endpoints
6262
export const crossSellTrain = '/v1/public/recommend/prod-prod/train';
6363
export const crossSellRelated = '/v1/public/recommend/prod-prod/';
64+
export const crossSellRelatedFull = '/v1/public/recommend/prod-prod/full/';

0 commit comments

Comments
 (0)