Skip to content

Commit

Permalink
refactor: group pr review & docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
dkonieczek committed Sep 17, 2024
1 parent e6eeca3 commit 4dd6889
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
14 changes: 7 additions & 7 deletions packages/snap-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const clientConfig = {

const client = new Client(globals, clientConfig);

const results = await client.search({
const response = await client.search({
search: {
query: {
string: 'dress'
Expand All @@ -163,7 +163,7 @@ const results = await client.search({
```typescript
const client = new Client(globals, clientConfig);

const [meta, results] = await client.search({
const { meta, results } = await client.search({
search: {
query: {
string: 'dress'
Expand All @@ -178,7 +178,7 @@ Makes a request to the Searchspring Search API and returns a promise.
```typescript
const client = new Client(globals, clientConfig);

const [meta, results] = await client.search({
const { meta, results } = await client.search({
search: {
query: {
string: 'dress'
Expand All @@ -193,7 +193,7 @@ Makes a request to the Searchspring Autocomplete API and returns a promise.
```typescript
const client = new Client(globals, clientConfig);

const [meta, results] = await client.autocomplete({
const { meta, results } = await client.autocomplete({
suggestions: {
count: 5
},
Expand All @@ -219,7 +219,7 @@ Makes a request to the Searchspring Trending API and returns a promise.

```typescript
const client = new Client(globals, clientConfig);
const results = await client.trending({
const trending = await client.trending({
siteId: 'abc123',
limit: 5
});
Expand All @@ -230,7 +230,7 @@ Makes a request to the Searchspring finder API and returns a promise.

```typescript
const client = new Client(globals, clientConfig);
const [meta, results] = await client.finder({
const { meta, results } = await client.finder({
filters: [{
type: "value",
field: "color",
Expand All @@ -245,7 +245,7 @@ Makes a request to the Searchspring Recommend API and returns a promise.

```typescript
const client = new Client(globals, clientConfig);
const results = await client.recommend({
const { profile, meta, recommend } = await client.recommend({
tag: 'similar',
siteId: 'abc123',
products: ['product123'],
Expand Down
5 changes: 2 additions & 3 deletions packages/snap-client/src/Client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,10 @@ export class Client {
return { meta, search };
}

async trending(params: Partial<TrendingRequestModel>): Promise<{ trending: TrendingResponseModel }> {
async trending(params: Partial<TrendingRequestModel>): Promise<TrendingResponseModel> {
params = deepmerge({ siteId: this.globals.siteId }, params || {});

const trending = await this.requesters.suggest.getTrending(params as TrendingRequestModel);
return { trending };
return this.requesters.suggest.getTrending(params as TrendingRequestModel);
}

async recommend(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,11 @@ export class AutocompleteController extends AbstractController {

const trendingProfile = this.profiler.create({ type: 'event', name: 'trending', context: trendingParams }).start();

const response = await this.client.trending(trendingParams);
trending = response.trending;
trending = await this.client.trending(trendingParams);

trendingProfile.stop();
this.log.profile(trendingProfile);
if (trending?.trending?.queries?.length) {
if (trending?.trending.queries?.length) {
this.storage.set('terms', JSON.stringify(trending));
}
}
Expand Down
5 changes: 2 additions & 3 deletions packages/snap-shared/src/MockClient/MockClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ export class MockClient extends Client {
return this.mockData.recommend();
}

async trending(): Promise<{ trending: TrendingResponseModel }> {
async trending(): Promise<TrendingResponseModel> {
if (this.mockConfig.delay) await wait(this.mockConfig.delay);

const trending = this.mockData.trending();
return { trending };
return this.mockData.trending();
}
}

Expand Down

0 comments on commit 4dd6889

Please sign in to comment.