@@ -146,6 +146,7 @@ var executeApiFetch = function(apiHostname, sitekey, type, settings, cb, fuzzyRe
146
146
}
147
147
148
148
}
149
+ api = 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs ;
149
150
}
150
151
151
152
// Suggest
@@ -154,6 +155,7 @@ var executeApiFetch = function(apiHostname, sitekey, type, settings, cb, fuzzyRe
154
155
qs = settingToQueryParam ( settings . suggestionsSize , 'size' ) +
155
156
settingToQueryParam ( settings . lang , 'lang' ) ;
156
157
kw = settings . suggestionsPrefix ;
158
+ api = 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs ;
157
159
}
158
160
159
161
// Autocomplete
@@ -162,18 +164,20 @@ var executeApiFetch = function(apiHostname, sitekey, type, settings, cb, fuzzyRe
162
164
qs = settingToQueryParam ( settings . autocomplete . field , 'source' ) +
163
165
settingToQueryParam ( settings . autocomplete . size , 'size' ) ;
164
166
kw = settings . autocomplete . prefix ;
167
+ api = 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs ;
165
168
}
166
169
167
170
else if ( type === 'recommend' ) {
168
- apiPath = 'recommendations' ;
169
- qs = settingToQueryParam ( recommendOptions . itemId , 'itemId' ) ;
171
+ if ( recommendOptions . type === 'RELATED_ITEMS' ) {
172
+ qs = settingToQueryParam ( recommendOptions . itemId , 'itemId' ) ;
173
+ apiPath = 'recommendations/index/' + sitekey + '/block/' + recommendOptions . blockId + '?' + qs ;
174
+ } else if ( recommendOptions . type === 'FREQUENTLY_BOUGHT_TOGETHER' ) {
175
+ qs = settingToQueryParam ( recommendOptions . itemId , 'itemId' ) ;
176
+ apiPath = 'recommendations/' + sitekey + '?configurationKey=' + recommendOptions . configurationKey + qs ;
177
+ }
178
+ api = 'https://' + apiHostname + '/v1/' + apiPath ;
170
179
}
171
180
172
- // Execute API call
173
- api = type === 'recommend' ?
174
- 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?configurationKey=' + recommendOptions . configurationKey + qs :
175
- 'https://' + apiHostname + '/v1/' + apiPath + '/' + sitekey + '?term=' + kw + qs ;
176
-
177
181
apiInstance . get ( api )
178
182
. then ( function ( response ) {
179
183
var json = response . data ;
0 commit comments