|
1
|
import { generateCreateShippingOptionsData } from "./shipping-options" |
|
2
|
import { generateCreateFulfillmentData } from "./fulfillment" |
|
3
|
import { IFulfillmentModuleService } from "@medusajs/framework/types" |
|
4
|
|
|
5
|
export * from "./shipping-options" |
|
6
|
export * from "./fulfillment" |
|
7
|
export * from "./events" |
|
8
|
|
|
9
|
export async function createFullDataStructure( |
|
10
|
service: IFulfillmentModuleService, |
|
11
|
{ |
|
12
|
providerId, |
|
13
|
}: { |
|
14
|
providerId: string |
|
15
|
} |
|
16
|
) { |
|
17
|
const randomString = Math.random().toString(36).substring(7) |
|
18
|
|
|
19
|
const shippingProfile = await service.createShippingProfiles({ |
|
20
|
// generate random string |
|
21
|
name: "test_" + randomString, |
|
22
|
type: "default", |
|
23
|
}) |
|
24
|
const fulfillmentSet = await service.createFulfillmentSets({ |
|
25
|
name: "test_" + randomString, |
|
26
|
type: "test-type", |
|
27
|
}) |
|
28
|
const serviceZone = await service.createServiceZones({ |
|
29
|
name: "test_" + randomString, |
|
30
|
fulfillment_set_id: fulfillmentSet.id, |
|
31
|
geo_zones: [ |
|
32
|
{ |
|
33
|
type: "country", |
|
34
|
country_code: "US_" + randomString, |
|
35
|
}, |
|
36
|
], |
|
37
|
}) |
|
38
|
|
|
39
|
const shippingOption = await service.createShippingOptions( |
|
40
|
generateCreateShippingOptionsData({ |
|
41
|
provider_id: providerId, |
|
42
|
service_zone_id: serviceZone.id, |
|
43
|
shipping_profile_id: shippingProfile.id, |
|
44
|
}) |
|
45
|
) |
|
46
|
|
|
47
|
await service.createFulfillment( |
|
48
|
generateCreateFulfillmentData({ |
|
49
|
provider_id: providerId, |
|
50
|
shipping_option_id: shippingOption.id, |
|
51
|
}) |
|
52
|
) |
|
53
|
} |