Skip to content

Commit

Permalink
Merge pull request #43 from Relewise/feat-cancellation-support
Browse files Browse the repository at this point in the history
feat: cancellation support
  • Loading branch information
mzanoni authored Oct 23, 2023
2 parents 2653f96 + f95a926 commit a370f32
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 95 deletions.
118 changes: 59 additions & 59 deletions lib/src/recommender.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RelewiseClient, RelewiseClientOptions } from './relewise.client';
import { RelewiseClient, RelewiseClientOptions, RelewiseRequestOptions } from './relewise.client';
import {
ProductRecommendationResponse,
ContentRecommendationResponse,
Expand Down Expand Up @@ -46,139 +46,139 @@ export class Recommender extends RelewiseClient {
super(datasetId, apiKey, options);
}

public async recommendPopularSearchTerms(request: PopularSearchTermsRecommendationRequest): Promise<SearchTermRecommendationResponse | undefined> {
return this.request<PopularSearchTermsRecommendationRequest, SearchTermRecommendationResponse>('PopularSearchTermsRecommendationRequest', request);
public async recommendPopularSearchTerms(request: PopularSearchTermsRecommendationRequest, options?: RelewiseRequestOptions): Promise<SearchTermRecommendationResponse | undefined> {
return this.request<PopularSearchTermsRecommendationRequest, SearchTermRecommendationResponse>('PopularSearchTermsRecommendationRequest', request, options);
}

//#region Brands

public async recommendPersonalBrands(request: PersonalBrandRecommendationRequest): Promise<BrandRecommendationResponse | undefined> {
return this.request<PersonalBrandRecommendationRequest, BrandRecommendationResponse>('PersonalBrandRecommendationRequest', request);
public async recommendPersonalBrands(request: PersonalBrandRecommendationRequest, options?: RelewiseRequestOptions): Promise<BrandRecommendationResponse | undefined> {
return this.request<PersonalBrandRecommendationRequest, BrandRecommendationResponse>('PersonalBrandRecommendationRequest', request, options);
}

public async recommendPopularBrands(request: PopularBrandsRecommendationRequest): Promise<BrandRecommendationResponse | undefined> {
return this.request<PopularBrandsRecommendationRequest, BrandRecommendationResponse>('PopularBrandsRecommendationRequest', request);
public async recommendPopularBrands(request: PopularBrandsRecommendationRequest, options?: RelewiseRequestOptions): Promise<BrandRecommendationResponse | undefined> {
return this.request<PopularBrandsRecommendationRequest, BrandRecommendationResponse>('PopularBrandsRecommendationRequest', request, options);
}

//#endregion

//#region Content Categories
public async recommendPersonalContentCategories(request: PersonalContentCategoryRecommendationRequest): Promise<ContentCategoryRecommendationResponse | undefined> {
return this.request<PersonalContentCategoryRecommendationRequest, ContentCategoryRecommendationResponse>('PersonalContentCategoryRecommendationRequest', request);
public async recommendPersonalContentCategories(request: PersonalContentCategoryRecommendationRequest, options?: RelewiseRequestOptions): Promise<ContentCategoryRecommendationResponse | undefined> {
return this.request<PersonalContentCategoryRecommendationRequest, ContentCategoryRecommendationResponse>('PersonalContentCategoryRecommendationRequest', request, options);
}

public async recommendPopularContentCategories(request: PopularContentCategoriesRecommendationRequest): Promise<ContentCategoryRecommendationResponse | undefined> {
return this.request<PopularContentCategoriesRecommendationRequest, ContentCategoryRecommendationResponse>('PopularContentCategoriesRecommendationRequest', request);
public async recommendPopularContentCategories(request: PopularContentCategoriesRecommendationRequest, options?: RelewiseRequestOptions): Promise<ContentCategoryRecommendationResponse | undefined> {
return this.request<PopularContentCategoriesRecommendationRequest, ContentCategoryRecommendationResponse>('PopularContentCategoriesRecommendationRequest', request, options);
}

//#endregion

//#region Product Categories
public async recommendPersonalProductCategories(request: PersonalProductCategoryRecommendationRequest): Promise<ProductCategoryRecommendationResponse | undefined> {
return this.request<PersonalProductCategoryRecommendationRequest, ProductCategoryRecommendationResponse>('PersonalProductCategoryRecommendationRequest', request);
public async recommendPersonalProductCategories(request: PersonalProductCategoryRecommendationRequest, options?: RelewiseRequestOptions): Promise<ProductCategoryRecommendationResponse | undefined> {
return this.request<PersonalProductCategoryRecommendationRequest, ProductCategoryRecommendationResponse>('PersonalProductCategoryRecommendationRequest', request, options);
}

public async recommendPopularProductCategories(request: PopularProductCategoriesRecommendationRequest): Promise<ProductCategoryRecommendationResponse | undefined> {
return this.request<PopularProductCategoriesRecommendationRequest, ProductCategoryRecommendationResponse>('PopularProductCategoriesRecommendationRequest', request);
public async recommendPopularProductCategories(request: PopularProductCategoriesRecommendationRequest, options?: RelewiseRequestOptions): Promise<ProductCategoryRecommendationResponse | undefined> {
return this.request<PopularProductCategoriesRecommendationRequest, ProductCategoryRecommendationResponse>('PopularProductCategoriesRecommendationRequest', request, options);
}

//#endregion

//#region Products

public async recommendPurchasedWithProduct(request: PurchasedWithProductRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<PurchasedWithProductRequest, ProductRecommendationResponse>('PurchasedWithProductRequest', request);
public async recommendPurchasedWithProduct(request: PurchasedWithProductRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<PurchasedWithProductRequest, ProductRecommendationResponse>('PurchasedWithProductRequest', request, options);
}

public async recommendPurchasedWithMultipleProducts(request: PurchasedWithMultipleProductsRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<PurchasedWithMultipleProductsRequest, ProductRecommendationResponse>('PurchasedWithMultipleProductsRequest', request);
public async recommendPurchasedWithMultipleProducts(request: PurchasedWithMultipleProductsRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<PurchasedWithMultipleProductsRequest, ProductRecommendationResponse>('PurchasedWithMultipleProductsRequest', request, options);
}

public async sortVariants(request: SortVariantsRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<SortVariantsRequest, ProductRecommendationResponse>('SortVariantsRequest', request);
public async sortVariants(request: SortVariantsRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<SortVariantsRequest, ProductRecommendationResponse>('SortVariantsRequest', request, options);
}

public async sortProducts(request: SortProductsRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<SortProductsRequest, ProductRecommendationResponse>('SortProductsRequest', request);
public async sortProducts(request: SortProductsRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<SortProductsRequest, ProductRecommendationResponse>('SortProductsRequest', request, options);
}

public async recommendSimilarProducts(request: SimilarProductsRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<SimilarProductsRequest, ProductRecommendationResponse>('SimilarProductsRequest', request);
public async recommendSimilarProducts(request: SimilarProductsRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<SimilarProductsRequest, ProductRecommendationResponse>('SimilarProductsRequest', request, options);
}

public async recommendSearchTermBasedProducts(request: SearchTermBasedProductRecommendationRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<SearchTermBasedProductRecommendationRequest, ProductRecommendationResponse>('SearchTermBasedProductRecommendationRequest', request);
public async recommendSearchTermBasedProducts(request: SearchTermBasedProductRecommendationRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<SearchTermBasedProductRecommendationRequest, ProductRecommendationResponse>('SearchTermBasedProductRecommendationRequest', request, options);
}

public async recentlyViewedProducts(request: RecentlyViewedProductsRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<RecentlyViewedProductsRequest, ProductRecommendationResponse>('RecentlyViewedProductsRequest', request);
public async recentlyViewedProducts(request: RecentlyViewedProductsRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<RecentlyViewedProductsRequest, ProductRecommendationResponse>('RecentlyViewedProductsRequest', request, options);
}

public async recommendPurchasedWithCurrentCart(request: PurchasedWithCurrentCartRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<PurchasedWithCurrentCartRequest, ProductRecommendationResponse>('PurchasedWithCurrentCartRequest', request);
public async recommendPurchasedWithCurrentCart(request: PurchasedWithCurrentCartRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<PurchasedWithCurrentCartRequest, ProductRecommendationResponse>('PurchasedWithCurrentCartRequest', request, options);
}

public async recommendProductsViewedAfterViewingProduct(request: ProductsViewedAfterViewingProductRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<ProductsViewedAfterViewingProductRequest, ProductRecommendationResponse>('ProductsViewedAfterViewingProductRequest', request);
public async recommendProductsViewedAfterViewingProduct(request: ProductsViewedAfterViewingProductRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<ProductsViewedAfterViewingProductRequest, ProductRecommendationResponse>('ProductsViewedAfterViewingProductRequest', request, options);
}

public async recommendProductsViewedAfterViewingContent(request: ProductsViewedAfterViewingContentRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<ProductsViewedAfterViewingContentRequest, ProductRecommendationResponse>('ProductsViewedAfterViewingContentRequest', request);
public async recommendProductsViewedAfterViewingContent(request: ProductsViewedAfterViewingContentRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<ProductsViewedAfterViewingContentRequest, ProductRecommendationResponse>('ProductsViewedAfterViewingContentRequest', request, options);
}

public async recommendPopularProducts(request: PopularProductsRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<PopularProductsRequest, ProductRecommendationResponse>('PopularProductsRequest', request);
public async recommendPopularProducts(request: PopularProductsRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<PopularProductsRequest, ProductRecommendationResponse>('PopularProductsRequest', request, options);
}

public async recommendPersonalProducts(request: PersonalProductRecommendationRequest): Promise<ProductRecommendationResponse | undefined> {
return this.request<PersonalProductRecommendationRequest, ProductRecommendationResponse>('PersonalProductRecommendationRequest', request);
public async recommendPersonalProducts(request: PersonalProductRecommendationRequest, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponse | undefined> {
return this.request<PersonalProductRecommendationRequest, ProductRecommendationResponse>('PersonalProductRecommendationRequest', request, options);
}

//#endregion

//#region Content

public async recommendPopularContents(request: PopularContentsRequest): Promise<ContentRecommendationResponse | undefined> {
return this.request<PopularContentsRequest, ContentRecommendationResponse>('PopularContentsRequest', request);
public async recommendPopularContents(request: PopularContentsRequest, options?: RelewiseRequestOptions): Promise<ContentRecommendationResponse | undefined> {
return this.request<PopularContentsRequest, ContentRecommendationResponse>('PopularContentsRequest', request, options);
}

public async recommendPersonalContents(request: PersonalContentRecommendationRequest): Promise<ContentRecommendationResponse | undefined> {
return this.request<PersonalContentRecommendationRequest, ContentRecommendationResponse>('PopularContentsRequest', request);
public async recommendPersonalContents(request: PersonalContentRecommendationRequest, options?: RelewiseRequestOptions): Promise<ContentRecommendationResponse | undefined> {
return this.request<PersonalContentRecommendationRequest, ContentRecommendationResponse>('PopularContentsRequest', request, options);
}

public async recommendContentsViewedAfterViewingProduct(request: ContentsViewedAfterViewingProductRequest): Promise<ContentRecommendationResponse | undefined> {
return this.request<ContentsViewedAfterViewingProductRequest, ContentRecommendationResponse>('ContentsViewedAfterViewingProductRequest', request);
public async recommendContentsViewedAfterViewingProduct(request: ContentsViewedAfterViewingProductRequest, options?: RelewiseRequestOptions): Promise<ContentRecommendationResponse | undefined> {
return this.request<ContentsViewedAfterViewingProductRequest, ContentRecommendationResponse>('ContentsViewedAfterViewingProductRequest', request, options);
}

public async recommendContentsViewedAfterViewingMultipleProducts(request: ContentsViewedAfterViewingMultipleProductsRequest): Promise<ContentRecommendationResponse | undefined> {
return this.request<ContentsViewedAfterViewingMultipleProductsRequest, ContentRecommendationResponse>('ContentsViewedAfterViewingProductRequest', request);
public async recommendContentsViewedAfterViewingMultipleProducts(request: ContentsViewedAfterViewingMultipleProductsRequest, options?: RelewiseRequestOptions): Promise<ContentRecommendationResponse | undefined> {
return this.request<ContentsViewedAfterViewingMultipleProductsRequest, ContentRecommendationResponse>('ContentsViewedAfterViewingProductRequest', request, options);
}

public async recommendContentsViewedAfterViewingMultipleContents(request: ContentsViewedAfterViewingMultipleContentsRequest): Promise<ContentRecommendationResponse | undefined> {
return this.request<ContentsViewedAfterViewingMultipleContentsRequest, ContentRecommendationResponse>('ContentsViewedAfterViewingMultipleContentsRequest', request);
public async recommendContentsViewedAfterViewingMultipleContents(request: ContentsViewedAfterViewingMultipleContentsRequest, options?: RelewiseRequestOptions): Promise<ContentRecommendationResponse | undefined> {
return this.request<ContentsViewedAfterViewingMultipleContentsRequest, ContentRecommendationResponse>('ContentsViewedAfterViewingMultipleContentsRequest', request, options);
}

public async recommendContentsViewedAfterViewingContent(request: ContentsViewedAfterViewingContentRequest): Promise<ContentRecommendationResponse | undefined> {
return this.request<ContentsViewedAfterViewingContentRequest, ContentRecommendationResponse>('ContentsViewedAfterViewingContentRequest', request);
public async recommendContentsViewedAfterViewingContent(request: ContentsViewedAfterViewingContentRequest, options?: RelewiseRequestOptions): Promise<ContentRecommendationResponse | undefined> {
return this.request<ContentsViewedAfterViewingContentRequest, ContentRecommendationResponse>('ContentsViewedAfterViewingContentRequest', request, options);
}

//#endregion

//#region Batching
public async batchProductRecommendations(request: ProductRecommendationRequestCollection): Promise<ProductRecommendationResponseCollection | undefined> {
return this.request<ProductRecommendationRequestCollection, ProductRecommendationResponseCollection>('ProductRecommendationRequestCollection', request);
public async batchProductRecommendations(request: ProductRecommendationRequestCollection, options?: RelewiseRequestOptions): Promise<ProductRecommendationResponseCollection | undefined> {
return this.request<ProductRecommendationRequestCollection, ProductRecommendationResponseCollection>('ProductRecommendationRequestCollection', request, options);
}

public async batchContentRecommendations(request: ContentRecommendationRequestCollection): Promise<ContentRecommendationResponseCollection | undefined> {
return this.request<ContentRecommendationRequestCollection, ContentRecommendationResponseCollection>('ContentRecommendationRequestCollection', request);
public async batchContentRecommendations(request: ContentRecommendationRequestCollection, options?: RelewiseRequestOptions): Promise<ContentRecommendationResponseCollection | undefined> {
return this.request<ContentRecommendationRequestCollection, ContentRecommendationResponseCollection>('ContentRecommendationRequestCollection', request, options);
}

public async batchContentCategoryRecommendations(request: ContentCategoryRecommendationRequestCollection): Promise<ContentCategoryRecommendationResponseCollection | undefined> {
return this.request<ContentCategoryRecommendationRequestCollection, ContentCategoryRecommendationResponseCollection>('ContentCategoryRecommendationRequestCollection', request);
public async batchContentCategoryRecommendations(request: ContentCategoryRecommendationRequestCollection, options?: RelewiseRequestOptions): Promise<ContentCategoryRecommendationResponseCollection | undefined> {
return this.request<ContentCategoryRecommendationRequestCollection, ContentCategoryRecommendationResponseCollection>('ContentCategoryRecommendationRequestCollection', request, options);
}

public async batchProductCategoryRecommendations(request: ProductCategoryRecommendationRequestCollection): Promise<ProductCategoryRecommendationResponseCollection | undefined> {
return this.request<ProductCategoryRecommendationRequestCollection, ProductCategoryRecommendationResponseCollection>('ProductCategoryRecommendationRequestCollection', request);
public async batchProductCategoryRecommendations(request: ProductCategoryRecommendationRequestCollection, options?: RelewiseRequestOptions): Promise<ProductCategoryRecommendationResponseCollection | undefined> {
return this.request<ProductCategoryRecommendationRequestCollection, ProductCategoryRecommendationResponseCollection>('ProductCategoryRecommendationRequestCollection', request, options);
}

//#endregion
Expand Down
Loading

0 comments on commit a370f32

Please sign in to comment.