@@ -6,8 +6,9 @@ import io.constructor.data.ConstructorData
66import io.constructor.data.DataManager
77import io.constructor.data.local.PreferencesHelper
88import io.constructor.data.memory.ConfigMemoryHolder
9- import io.constructor.data.model.Group
10- import io.constructor.data.model.Suggestion
9+ import io.constructor.data.model.autocomplete.AutocompleteResponse
10+ import io.constructor.data.model.common.Result
11+ import io.constructor.data.model.common.ResultGroup
1112import io.constructor.data.model.search.SearchResponse
1213import io.constructor.data.model.browse.BrowseResponse
1314import io.constructor.injection.component.AppComponent
@@ -96,7 +97,7 @@ object ConstructorIo {
9697 /* *
9798 * Returns a list of autocomplete suggestions
9899 */
99- fun getAutocompleteResults (query : String ): Observable <ConstructorData <List < Suggestion > ? >> {
100+ fun getAutocompleteResults (query : String ): Observable <ConstructorData <AutocompleteResponse >> {
100101 val params = mutableListOf<Pair <String , String >>()
101102 configMemoryHolder.autocompleteResultCount?.entries?.forEach {
102103 params.add(Pair (Constants .QueryConstants .NUM_RESULTS + it.key, it.value.toString()))
@@ -156,19 +157,19 @@ object ConstructorIo {
156157 /* *
157158 * Tracks autocomplete select events
158159 */
159- fun trackAutocompleteSelect (searchTerm : String , originalQuery : String , sectionName : String , group : Group ? = null, resultID : String? = null) {
160- var completable = trackAutocompleteSelectInternal(searchTerm, originalQuery, sectionName, group , resultID);
160+ fun trackAutocompleteSelect (searchTerm : String , originalQuery : String , sectionName : String , resultGroup : ResultGroup ? = null, resultID : String? = null) {
161+ var completable = trackAutocompleteSelectInternal(searchTerm, originalQuery, sectionName, resultGroup , resultID);
161162 disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({
162163 context.broadcastIntent(Constants .EVENT_QUERY_SENT , Constants .EXTRA_TERM to searchTerm)
163164 }, {
164165 t -> e(" Autocomplete Select error: ${t.message} " )
165166 }))
166167 }
167- internal fun trackAutocompleteSelectInternal (searchTerm : String , originalQuery : String , sectionName : String , group : Group ? = null, resultID : String? = null): Completable {
168+ internal fun trackAutocompleteSelectInternal (searchTerm : String , originalQuery : String , sectionName : String , resultGroup : ResultGroup ? = null, resultID : String? = null): Completable {
168169 preferenceHelper.getSessionId(sessionIncrementHandler)
169170 val encodedParams: ArrayList <Pair <String , String >> = arrayListOf ()
170- group ?.groupId?.let { encodedParams.add(Constants .QueryConstants .GROUP_ID .urlEncode() to it) }
171- group ?.displayName?.let { encodedParams.add(Constants .QueryConstants .GROUP_DISPLAY_NAME .urlEncode() to it.urlEncode()) }
171+ resultGroup ?.groupId?.let { encodedParams.add(Constants .QueryConstants .GROUP_ID .urlEncode() to it) }
172+ resultGroup ?.displayName?.let { encodedParams.add(Constants .QueryConstants .GROUP_DISPLAY_NAME .urlEncode() to it.urlEncode()) }
172173 resultID?.let { encodedParams.add(Constants .QueryConstants .RESULT_ID .urlEncode() to it.urlEncode()) }
173174 return dataManager.trackAutocompleteSelect(searchTerm, arrayOf(
174175 Constants .QueryConstants .AUTOCOMPLETE_SECTION to sectionName,
@@ -180,19 +181,19 @@ object ConstructorIo {
180181 /* *
181182 * Tracks search submit events
182183 */
183- fun trackSearchSubmit (searchTerm : String , originalQuery : String , group : Group ? ) {
184- var completable = trackSearchSubmitInternal(searchTerm, originalQuery, group )
184+ fun trackSearchSubmit (searchTerm : String , originalQuery : String , resultGroup : ResultGroup ? ) {
185+ var completable = trackSearchSubmitInternal(searchTerm, originalQuery, resultGroup )
185186 disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({
186187 context.broadcastIntent(Constants .EVENT_QUERY_SENT , Constants .EXTRA_TERM to searchTerm)
187188 }, {
188189 t -> e(" Search Submit error: ${t.message} " )
189190 }))
190191 }
191- internal fun trackSearchSubmitInternal (searchTerm : String , originalQuery : String , group : Group ? ): Completable {
192+ internal fun trackSearchSubmitInternal (searchTerm : String , originalQuery : String , resultGroup : ResultGroup ? ): Completable {
192193 preferenceHelper.getSessionId(sessionIncrementHandler)
193194 val encodedParams: ArrayList <Pair <String , String >> = arrayListOf ()
194- group ?.groupId?.let { encodedParams.add(Constants .QueryConstants .GROUP_ID .urlEncode() to it) }
195- group ?.displayName?.let { encodedParams.add(Constants .QueryConstants .GROUP_DISPLAY_NAME .urlEncode() to it.urlEncode()) }
195+ resultGroup ?.groupId?.let { encodedParams.add(Constants .QueryConstants .GROUP_ID .urlEncode() to it) }
196+ resultGroup ?.displayName?.let { encodedParams.add(Constants .QueryConstants .GROUP_DISPLAY_NAME .urlEncode() to it.urlEncode()) }
196197 return dataManager.trackSearchSubmit(searchTerm, arrayOf(
197198 Constants .QueryConstants .ORIGINAL_QUERY to originalQuery,
198199 Constants .QueryConstants .EVENT to Constants .QueryValues .EVENT_SEARCH
0 commit comments