Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/api-v4/src/marketplace/marketplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const getMarketplaceProducts = (params?: Params, filters?: Filter) =>
export const getMarketplaceProduct = (productId: number) =>
Request<MarketplaceProduct>(
setURL(
`${BETA_API_ROOT}/marketplace/products/${encodeURIComponent(productId)}`,
`${BETA_API_ROOT}/marketplace/products/${encodeURIComponent(productId)}/details`,
),
setMethod('GET'),
);
Expand Down
35 changes: 26 additions & 9 deletions packages/api-v4/src/marketplace/types.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,59 @@
export interface MarketplaceProductDetail {
documentation: string;
overview: {
documentation?: string;
overview?: {
description: string;
};
pricing: string;
support: string;
pricing?: string;
support?: string;
}

export interface MarketplaceProduct {
category_ids: number[];
created_at: string;
created_by: string;
details?: MarketplaceProductDetail;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but I don't see details marked as optional anywhere. Still it's worth checking

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Details is the part of the /products/{id}/details API only. Every other field is returned from both /products and /products/{id}/details

id: number;
info_banner?: string;
logo_url: string;
name: string;
partner_id: number;
product_tags?: string[];
short_description: string;
title_tag?: string;
tile_tag?: string;
type_id: number;
updated_at?: string;
updated_by?: string;
}

export interface MarketplaceCategory {
category: string;
created_at: string;
created_by: string;
id: number;
product_count: number;
name: string;
products_count: number;
updated_at?: string;
updated_by?: string;
}

export interface MarketplaceType {
created_at: string;
created_by: string;
id: number;
name: string;
product_count: number;
products_count: number;
updated_at?: string;
updated_by?: string;
}

export interface MarketplacePartner {
created_at: string;
created_by: string;
id: number;
logo_url_dark_mode: string;
logo_url_light_mode: string;
logo_url_night_mode?: string;
name: string;
updated_at?: string;
updated_by?: string;
url: string;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ const marketplace = [
const marketplaceProduct = marketplaceProductFactory.buildList(10);
return HttpResponse.json(makeResourcePage([...marketplaceProduct]));
}),
http.get('*/v4beta/marketplace/products/:productId', () => {
http.get('*/v4beta/marketplace/products/:productId/details', () => {
const marketplaceProductDetail = marketplaceProductFactory.build({
details: {
overview: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/queries": Upcoming Features
---

Add API queries for MarketplaceV2 ([#13255](https://github.com/linode/manager/pull/13255))
1 change: 1 addition & 0 deletions packages/queries/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './iam';
export * from './images';
export * from './linodes';
export * from './locks';
export * from './marketplace';
export * from './netloadbalancers';
export * from './networking';
export * from './networktransfer';
Expand Down
3 changes: 3 additions & 0 deletions packages/queries/src/marketplace/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './keys';
export * from './marketplace';
export * from './requests';
108 changes: 108 additions & 0 deletions packages/queries/src/marketplace/keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import {
getMarketplaceCategories,
getMarketplacePartners,
getMarketplaceProduct,
getMarketplaceProducts,
getMarketplaceTypes,
} from '@linode/api-v4';
import { createQueryKeys } from '@lukemorales/query-key-factory';

import {
getAllMarketplaceCategories,
getAllMarketplacePartners,
getAllMarketplaceProducts,
getAllMarketplaceTypes,
} from './requests';

import type { Filter, Params } from '@linode/api-v4';

export const marketplaceQueries = createQueryKeys('marketplace', {
product: (productId: number) => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now the api has changed from /marketplace/products/{id} to /marketplace/products/{id}/details

queryFn: () => getMarketplaceProduct(productId),
queryKey: [productId],
}),
products: {
contextQueries: {
all: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getAllMarketplaceProducts(params, filter),
queryKey: [params, filter],
}),
infinite: (filter: Filter = {}) => ({
queryFn: ({ pageParam }) =>
getMarketplaceProducts(
{ page: pageParam as number, page_size: 25 },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should page size be 25 for products api also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimum size for a page is 25

filter,
),
queryKey: [filter],
}),
paginated: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getMarketplaceProducts(params, filter),
queryKey: [params, filter],
}),
},
queryKey: null,
},
categories: {
contextQueries: {
all: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getAllMarketplaceCategories(params, filter),
queryKey: [params, filter],
}),
infinite: (filter: Filter = {}) => ({
queryFn: ({ pageParam }) =>
getMarketplaceCategories(
{ page: pageParam as number, page_size: 25 },
filter,
),
queryKey: [filter],
}),
paginated: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getMarketplaceCategories(params, filter),
queryKey: [params, filter],
}),
},
queryKey: null,
},
types: {
contextQueries: {
all: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getAllMarketplaceTypes(params, filter),
queryKey: [params, filter],
}),
infinite: (filter: Filter = {}) => ({
queryFn: ({ pageParam }) =>
getMarketplaceTypes(
{ page: pageParam as number, page_size: 25 },
filter,
),
queryKey: [filter],
}),
paginated: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getMarketplaceTypes(params, filter),
queryKey: [params, filter],
}),
},
queryKey: null,
},
partners: {
contextQueries: {
all: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getAllMarketplacePartners(params, filter),
queryKey: [params, filter],
}),
infinite: (filter: Filter = {}) => ({
queryFn: ({ pageParam }) =>
getMarketplacePartners(
{ page: pageParam as number, page_size: 25 },
filter,
),
queryKey: [filter],
}),
paginated: (params: Params = {}, filter: Filter = {}) => ({
queryFn: () => getMarketplacePartners(params, filter),
queryKey: [params, filter],
}),
},
queryKey: null,
},
});
Loading