Skip to content

Commit

Permalink
wip setup endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fPolic committed Dec 13, 2024
1 parent 729eb5d commit ab7fa8c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { BaseFulfillmentProvider } from "../common"
import {
BaseFulfillmentProvider,
BaseFulfillmentProviderOption,
} from "../common"

export interface AdminFulfillmentProvider extends BaseFulfillmentProvider {}

export interface AdminFulfillmentProviderOption
extends BaseFulfillmentProviderOption {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { PaginatedResponse } from "../../common"
import { AdminFulfillmentProvider } from "./entities"
import {
AdminFulfillmentProvider,
AdminFulfillmentProviderOption,
} from "./entities"

export interface AdminFulfillmentProviderListResponse
extends PaginatedResponse<{
Expand All @@ -8,3 +11,8 @@ export interface AdminFulfillmentProviderListResponse
*/
fulfillment_providers: AdminFulfillmentProvider[]
}> {}

export interface AdminFulfillmentProviderOptionsListResponse
extends PaginatedResponse<{
fulfillment_options: AdminFulfillmentProviderOption[]
}> {}
11 changes: 11 additions & 0 deletions packages/core/types/src/http/fulfillment-provider/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@ export interface BaseFulfillmentProvider {
*/
is_enabled: boolean
}

export interface BaseFulfillmentProviderOption {
/**
* The fulfillment provider option's ID.
*/
id: string
/**
* Whether the fulfillment provider option can be used for returns.
*/
is_returned: boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
AdminFulfillmentProviderOption,
HttpTypes,
} from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/framework/http"

export const GET = async (
req: AuthenticatedMedusaRequest,
res: MedusaResponse<HttpTypes.AdminFulfillmentProviderOptionsListResponse>
) => {
const fulfillmentProviderService = req.scope.resolve(Modules.FULFILLMENT)

const fulfillmentOptions =
await fulfillmentProviderService.retrieveFulfillmentOptions(req.params.id)

res.json({
fulfillment_options:
fulfillmentOptions as unknown as AdminFulfillmentProviderOption[],
count: fulfillmentOptions.length,
limit: fulfillmentOptions.length,
offset: 0,
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ export const adminFulfillmentProvidersRoutesMiddlewares: MiddlewareRoute[] = [
}),
],
},
{
method: ["GET"],
matcher: "/admin/fulfillment-providers/:id/options",
middlewares: [],
},
]

0 comments on commit ab7fa8c

Please sign in to comment.