@deliverart/sdk-js-order 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/config.json +11 -0
- package/.github/workflows/workflow.yml +47 -0
- package/.prettierrc +7 -0
- package/CHANGELOG.md +37 -0
- package/README.md +3 -0
- package/dist/index.cjs +1103 -0
- package/dist/index.d.cts +17403 -0
- package/dist/index.d.ts +17403 -0
- package/dist/index.js +1015 -0
- package/eslint.config.js +41 -0
- package/package.json +52 -0
- package/src/index.ts +3 -0
- package/src/models.ts +487 -0
- package/src/requests/bundles/CreateBundle.ts +29 -0
- package/src/requests/bundles/DeleteBundle.ts +27 -0
- package/src/requests/bundles/GetBundleDetails.ts +30 -0
- package/src/requests/bundles/GetBundles.ts +46 -0
- package/src/requests/bundles/UpdateBundle.ts +36 -0
- package/src/requests/bundles/index.ts +5 -0
- package/src/requests/index.ts +4 -0
- package/src/requests/order-menu-item-modifiers/GetOrderMenuItemModifierDetails.ts +33 -0
- package/src/requests/order-menu-item-modifiers/GetOrderMenuItemModifiers.ts +60 -0
- package/src/requests/order-menu-item-modifiers/index.ts +2 -0
- package/src/requests/order-menu-items/GetOrderMenuItemDetails.ts +33 -0
- package/src/requests/order-menu-items/GetOrderMenuItems.ts +54 -0
- package/src/requests/order-menu-items/index.ts +2 -0
- package/src/requests/orders/AdvanceOrderPreparationStatus.ts +33 -0
- package/src/requests/orders/ConfirmOrder.ts +30 -0
- package/src/requests/orders/CreateOrder.ts +48 -0
- package/src/requests/orders/DeleteOrder.ts +27 -0
- package/src/requests/orders/GetOrderDetails.ts +30 -0
- package/src/requests/orders/GetOrders.ts +42 -0
- package/src/requests/orders/UpdateOrder.ts +42 -0
- package/src/requests/orders/index.ts +7 -0
- package/src/types.ts +119 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import {
|
|
3
|
+
createPaginatedSchema,
|
|
4
|
+
Paginated,
|
|
5
|
+
responseToPagination,
|
|
6
|
+
} from '@deliverart/sdk-js-global-types'
|
|
7
|
+
import { AxiosResponse } from 'axios'
|
|
8
|
+
import { z } from 'zod'
|
|
9
|
+
|
|
10
|
+
import { Bundle, bundleSchema, BundlesQueryParams, bundlesQuerySchema } from '../../models'
|
|
11
|
+
|
|
12
|
+
export const getBundlesQuerySchema = bundlesQuerySchema
|
|
13
|
+
export type GetBundlesQueryParams = z.infer<typeof getBundlesQuerySchema>
|
|
14
|
+
|
|
15
|
+
export const getBundlesResponseSchema = createPaginatedSchema(bundleSchema)
|
|
16
|
+
export type GetBundlesResponse = z.infer<typeof getBundlesResponseSchema>
|
|
17
|
+
|
|
18
|
+
export const getBundlesInputSchema = z.undefined()
|
|
19
|
+
|
|
20
|
+
export class GetBundles extends AbstractApiRequest<
|
|
21
|
+
void,
|
|
22
|
+
GetBundlesResponse,
|
|
23
|
+
GetBundlesQueryParams
|
|
24
|
+
> {
|
|
25
|
+
readonly method = 'GET'
|
|
26
|
+
readonly contentType = 'application/json'
|
|
27
|
+
readonly accept = 'application/json'
|
|
28
|
+
|
|
29
|
+
readonly inputSchema = getBundlesInputSchema
|
|
30
|
+
readonly outputSchema = getBundlesResponseSchema
|
|
31
|
+
readonly querySchema = getBundlesQuerySchema
|
|
32
|
+
readonly headersSchema = undefined
|
|
33
|
+
|
|
34
|
+
constructor(options?: { query?: BundlesQueryParams }) {
|
|
35
|
+
super(undefined, options)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getPath(): string {
|
|
39
|
+
return '/bundles'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
parseResponse(data: unknown, rawResponse: AxiosResponse): Paginated<Bundle> {
|
|
43
|
+
const bundles = z.array(bundleSchema).parse(data)
|
|
44
|
+
return this.validateOutput({ data: bundles, pagination: responseToPagination(rawResponse) })
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { BundleDetails, bundleDetailsSchema, writableBundleSchema } from '../../models'
|
|
5
|
+
|
|
6
|
+
export const updateBundleInputSchema = writableBundleSchema
|
|
7
|
+
.omit({
|
|
8
|
+
pointOfSale: true,
|
|
9
|
+
})
|
|
10
|
+
.partial()
|
|
11
|
+
export type UpdateBundleInput = z.infer<typeof updateBundleInputSchema>
|
|
12
|
+
|
|
13
|
+
export const updateBundleResponseSchema = bundleDetailsSchema
|
|
14
|
+
export type UpdateBundleResponse = BundleDetails
|
|
15
|
+
|
|
16
|
+
export class UpdateBundle extends AbstractApiRequest<UpdateBundleInput, UpdateBundleResponse> {
|
|
17
|
+
readonly method = 'PATCH'
|
|
18
|
+
readonly contentType = 'application/merge-patch+json'
|
|
19
|
+
readonly accept = 'application/json'
|
|
20
|
+
|
|
21
|
+
readonly inputSchema = updateBundleInputSchema
|
|
22
|
+
readonly outputSchema = updateBundleResponseSchema
|
|
23
|
+
readonly querySchema = undefined
|
|
24
|
+
readonly headersSchema = undefined
|
|
25
|
+
|
|
26
|
+
private readonly bundleId: string
|
|
27
|
+
|
|
28
|
+
constructor(bundleId: string, input: UpdateBundleInput) {
|
|
29
|
+
super(input)
|
|
30
|
+
this.bundleId = bundleId
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getPath(): string {
|
|
34
|
+
return `/bundles/${this.bundleId}`
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { OrderMenuItemModifierDetails, orderMenuItemModifierDetailsSchema } from '../../models'
|
|
5
|
+
|
|
6
|
+
export const getOrderMenuItemModifierDetailsInputSchema = z.undefined()
|
|
7
|
+
|
|
8
|
+
export const getOrderMenuItemModifierDetailsResponseSchema = orderMenuItemModifierDetailsSchema
|
|
9
|
+
export type GetOrderMenuItemModifierDetailsResponse = OrderMenuItemModifierDetails
|
|
10
|
+
|
|
11
|
+
export class GetOrderMenuItemModifierModifierDetails extends AbstractApiRequest<
|
|
12
|
+
void,
|
|
13
|
+
GetOrderMenuItemModifierDetailsResponse
|
|
14
|
+
> {
|
|
15
|
+
readonly method = 'GET'
|
|
16
|
+
readonly contentType = 'application/json'
|
|
17
|
+
readonly accept = 'application/json'
|
|
18
|
+
readonly inputSchema = getOrderMenuItemModifierDetailsInputSchema
|
|
19
|
+
readonly outputSchema = getOrderMenuItemModifierDetailsResponseSchema
|
|
20
|
+
readonly querySchema = undefined
|
|
21
|
+
readonly headersSchema = undefined
|
|
22
|
+
|
|
23
|
+
private readonly orderMenuItemModifierId: string
|
|
24
|
+
|
|
25
|
+
constructor(orderMenuItemModifierId: string) {
|
|
26
|
+
super()
|
|
27
|
+
this.orderMenuItemModifierId = orderMenuItemModifierId
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getPath(): string {
|
|
31
|
+
return `/orders/menu_items/modifiers/${this.orderMenuItemModifierId}`
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import {
|
|
3
|
+
createPaginatedSchema,
|
|
4
|
+
Paginated,
|
|
5
|
+
responseToPagination,
|
|
6
|
+
} from '@deliverart/sdk-js-global-types'
|
|
7
|
+
import { AxiosResponse } from 'axios'
|
|
8
|
+
import { z } from 'zod'
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
OrderMenuItemModifier,
|
|
12
|
+
orderMenuItemModifierSchema,
|
|
13
|
+
OrderMenuItemModifiersQueryParams,
|
|
14
|
+
orderMenuItemModifiersQuerySchema,
|
|
15
|
+
} from '../../models'
|
|
16
|
+
|
|
17
|
+
export const getOrderMenuItemModifiersQuerySchema = orderMenuItemModifiersQuerySchema
|
|
18
|
+
export type GetOrderMenuItemModifiersQueryParams = z.infer<
|
|
19
|
+
typeof getOrderMenuItemModifiersQuerySchema
|
|
20
|
+
>
|
|
21
|
+
|
|
22
|
+
export const getOrderMenuItemModifiersResponseSchema = createPaginatedSchema(
|
|
23
|
+
orderMenuItemModifierSchema,
|
|
24
|
+
)
|
|
25
|
+
export type GetOrderMenuItemModifiersResponse = z.infer<
|
|
26
|
+
typeof getOrderMenuItemModifiersResponseSchema
|
|
27
|
+
>
|
|
28
|
+
|
|
29
|
+
export const getOrderMenuItemModifiersInputSchema = z.undefined()
|
|
30
|
+
|
|
31
|
+
export class GetOrderMenuItemModifierMenuItemModifiers extends AbstractApiRequest<
|
|
32
|
+
void,
|
|
33
|
+
GetOrderMenuItemModifiersResponse,
|
|
34
|
+
GetOrderMenuItemModifiersQueryParams
|
|
35
|
+
> {
|
|
36
|
+
readonly method = 'GET'
|
|
37
|
+
readonly contentType = 'application/json'
|
|
38
|
+
readonly accept = 'application/json'
|
|
39
|
+
|
|
40
|
+
readonly inputSchema = getOrderMenuItemModifiersInputSchema
|
|
41
|
+
readonly outputSchema = getOrderMenuItemModifiersResponseSchema
|
|
42
|
+
readonly querySchema = getOrderMenuItemModifiersQuerySchema
|
|
43
|
+
readonly headersSchema = undefined
|
|
44
|
+
|
|
45
|
+
constructor(options?: { query?: OrderMenuItemModifiersQueryParams }) {
|
|
46
|
+
super(undefined, options)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getPath(): string {
|
|
50
|
+
return '/orders/menu_items/modifiers'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
parseResponse(data: unknown, rawResponse: AxiosResponse): Paginated<OrderMenuItemModifier> {
|
|
54
|
+
const orderMenuItemModifiers = z.array(orderMenuItemModifierSchema).parse(data)
|
|
55
|
+
return this.validateOutput({
|
|
56
|
+
data: orderMenuItemModifiers,
|
|
57
|
+
pagination: responseToPagination(rawResponse),
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { OrderMenuItemDetails, orderMenuItemDetailsSchema } from '../../models'
|
|
5
|
+
|
|
6
|
+
export const getOrderMenuItemDetailsInputSchema = z.undefined()
|
|
7
|
+
|
|
8
|
+
export const getOrderMenuItemDetailsResponseSchema = orderMenuItemDetailsSchema
|
|
9
|
+
export type GetOrderMenuItemDetailsResponse = OrderMenuItemDetails
|
|
10
|
+
|
|
11
|
+
export class GetOrderMenuItemDetails extends AbstractApiRequest<
|
|
12
|
+
void,
|
|
13
|
+
GetOrderMenuItemDetailsResponse
|
|
14
|
+
> {
|
|
15
|
+
readonly method = 'GET'
|
|
16
|
+
readonly contentType = 'application/json'
|
|
17
|
+
readonly accept = 'application/json'
|
|
18
|
+
readonly inputSchema = getOrderMenuItemDetailsInputSchema
|
|
19
|
+
readonly outputSchema = getOrderMenuItemDetailsResponseSchema
|
|
20
|
+
readonly querySchema = undefined
|
|
21
|
+
readonly headersSchema = undefined
|
|
22
|
+
|
|
23
|
+
private readonly orderMenuItemId: string
|
|
24
|
+
|
|
25
|
+
constructor(orderMenuItemId: string) {
|
|
26
|
+
super()
|
|
27
|
+
this.orderMenuItemId = orderMenuItemId
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getPath(): string {
|
|
31
|
+
return `/orders/menu_items/${this.orderMenuItemId}`
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import {
|
|
3
|
+
createPaginatedSchema,
|
|
4
|
+
Paginated,
|
|
5
|
+
responseToPagination,
|
|
6
|
+
} from '@deliverart/sdk-js-global-types'
|
|
7
|
+
import { AxiosResponse } from 'axios'
|
|
8
|
+
import { z } from 'zod'
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
OrderMenuItem,
|
|
12
|
+
orderMenuItemSchema,
|
|
13
|
+
OrderMenuItemsQueryParams,
|
|
14
|
+
orderMenuItemsQuerySchema,
|
|
15
|
+
} from '../../models'
|
|
16
|
+
|
|
17
|
+
export const getOrderMenuItemsQuerySchema = orderMenuItemsQuerySchema
|
|
18
|
+
export type GetOrderMenuItemsQueryParams = z.infer<typeof getOrderMenuItemsQuerySchema>
|
|
19
|
+
|
|
20
|
+
export const getOrderMenuItemsResponseSchema = createPaginatedSchema(orderMenuItemSchema)
|
|
21
|
+
export type GetOrderMenuItemsResponse = z.infer<typeof getOrderMenuItemsResponseSchema>
|
|
22
|
+
|
|
23
|
+
export const getOrderMenuItemsInputSchema = z.undefined()
|
|
24
|
+
|
|
25
|
+
export class GetOrderMenuItemMenuItems extends AbstractApiRequest<
|
|
26
|
+
void,
|
|
27
|
+
GetOrderMenuItemsResponse,
|
|
28
|
+
GetOrderMenuItemsQueryParams
|
|
29
|
+
> {
|
|
30
|
+
readonly method = 'GET'
|
|
31
|
+
readonly contentType = 'application/json'
|
|
32
|
+
readonly accept = 'application/json'
|
|
33
|
+
|
|
34
|
+
readonly inputSchema = getOrderMenuItemsInputSchema
|
|
35
|
+
readonly outputSchema = getOrderMenuItemsResponseSchema
|
|
36
|
+
readonly querySchema = getOrderMenuItemsQuerySchema
|
|
37
|
+
readonly headersSchema = undefined
|
|
38
|
+
|
|
39
|
+
constructor(options?: { query?: OrderMenuItemsQueryParams }) {
|
|
40
|
+
super(undefined, options)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getPath(): string {
|
|
44
|
+
return '/orders/menu_items'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
parseResponse(data: unknown, rawResponse: AxiosResponse): Paginated<OrderMenuItem> {
|
|
48
|
+
const orderMenuItems = z.array(orderMenuItemSchema).parse(data)
|
|
49
|
+
return this.validateOutput({
|
|
50
|
+
data: orderMenuItems,
|
|
51
|
+
pagination: responseToPagination(rawResponse),
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { OrderDetails, orderDetailsSchema } from '../../models'
|
|
5
|
+
|
|
6
|
+
export const advanceOrderPreparationStatusInputSchema = z.undefined()
|
|
7
|
+
|
|
8
|
+
export const advanceOrderPreparationStatusResponseSchema = orderDetailsSchema
|
|
9
|
+
export type AdvanceOrderPreparationStatusResponse = OrderDetails
|
|
10
|
+
|
|
11
|
+
export class AdvanceOrderPreparationStatus extends AbstractApiRequest<
|
|
12
|
+
void,
|
|
13
|
+
AdvanceOrderPreparationStatusResponse
|
|
14
|
+
> {
|
|
15
|
+
readonly method = 'POST'
|
|
16
|
+
readonly contentType = 'application/json'
|
|
17
|
+
readonly accept = 'application/json'
|
|
18
|
+
readonly inputSchema = advanceOrderPreparationStatusInputSchema
|
|
19
|
+
readonly outputSchema = advanceOrderPreparationStatusResponseSchema
|
|
20
|
+
readonly querySchema = undefined
|
|
21
|
+
readonly headersSchema = undefined
|
|
22
|
+
|
|
23
|
+
private readonly orderId: string
|
|
24
|
+
|
|
25
|
+
constructor(orderId: string) {
|
|
26
|
+
super()
|
|
27
|
+
this.orderId = orderId
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getPath(): string {
|
|
31
|
+
return `/orders/${this.orderId}/preparation/advance`
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { OrderDetails, orderDetailsSchema } from '../../models'
|
|
5
|
+
|
|
6
|
+
export const confirmOrderInputSchema = z.undefined()
|
|
7
|
+
|
|
8
|
+
export const confirmOrderResponseSchema = orderDetailsSchema
|
|
9
|
+
export type ConfirmOrderResponse = OrderDetails
|
|
10
|
+
|
|
11
|
+
export class ConfirmOrder extends AbstractApiRequest<void, ConfirmOrderResponse> {
|
|
12
|
+
readonly method = 'POST'
|
|
13
|
+
readonly contentType = 'application/json'
|
|
14
|
+
readonly accept = 'application/json'
|
|
15
|
+
readonly inputSchema = confirmOrderInputSchema
|
|
16
|
+
readonly outputSchema = confirmOrderResponseSchema
|
|
17
|
+
readonly querySchema = undefined
|
|
18
|
+
readonly headersSchema = undefined
|
|
19
|
+
|
|
20
|
+
private readonly orderId: string
|
|
21
|
+
|
|
22
|
+
constructor(orderId: string) {
|
|
23
|
+
super()
|
|
24
|
+
this.orderId = orderId
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getPath(): string {
|
|
28
|
+
return `/orders/${this.orderId}/confirm`
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { OrderDetails, orderDetailsSchema, writableOrderSchema } from '../../models'
|
|
5
|
+
|
|
6
|
+
export const createOrderInputSchema = writableOrderSchema.required().partial({
|
|
7
|
+
customer: true,
|
|
8
|
+
customerBusinessProfile: true,
|
|
9
|
+
referenceBundle: true,
|
|
10
|
+
partner: true,
|
|
11
|
+
partnerIdentifier: true,
|
|
12
|
+
displayId: true,
|
|
13
|
+
autoAccept: true,
|
|
14
|
+
customerInfo: true,
|
|
15
|
+
billingInfo: true,
|
|
16
|
+
address: true,
|
|
17
|
+
preparationStatus: true,
|
|
18
|
+
preparationTime: true,
|
|
19
|
+
deliveryTime: true,
|
|
20
|
+
collectionTime: true,
|
|
21
|
+
discount: true,
|
|
22
|
+
notes: true,
|
|
23
|
+
deliveryNotes: true,
|
|
24
|
+
kitchenNotes: true,
|
|
25
|
+
})
|
|
26
|
+
export type CreateOrderInput = z.infer<typeof createOrderInputSchema>
|
|
27
|
+
|
|
28
|
+
export const createOrderResponseSchema = orderDetailsSchema
|
|
29
|
+
export type CreateOrderResponse = OrderDetails
|
|
30
|
+
|
|
31
|
+
export class CreateOrder extends AbstractApiRequest<CreateOrderInput, CreateOrderResponse> {
|
|
32
|
+
readonly method = 'POST'
|
|
33
|
+
readonly contentType = 'application/json'
|
|
34
|
+
readonly accept = 'application/json'
|
|
35
|
+
|
|
36
|
+
readonly inputSchema = createOrderInputSchema
|
|
37
|
+
readonly outputSchema = createOrderResponseSchema
|
|
38
|
+
readonly querySchema = undefined
|
|
39
|
+
readonly headersSchema = undefined
|
|
40
|
+
|
|
41
|
+
constructor(input: CreateOrderInput) {
|
|
42
|
+
super(input)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getPath(): string {
|
|
46
|
+
return '/orders'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
export const deleteOrderInputSchema = z.undefined()
|
|
5
|
+
export const deleteOrderResponseSchema = z.undefined()
|
|
6
|
+
|
|
7
|
+
export class DeleteOrder extends AbstractApiRequest<void, void> {
|
|
8
|
+
readonly method = 'DELETE'
|
|
9
|
+
readonly contentType = 'application/json'
|
|
10
|
+
readonly accept = 'application/json'
|
|
11
|
+
|
|
12
|
+
readonly inputSchema = deleteOrderInputSchema
|
|
13
|
+
readonly outputSchema = deleteOrderResponseSchema
|
|
14
|
+
readonly querySchema = undefined
|
|
15
|
+
readonly headersSchema = undefined
|
|
16
|
+
|
|
17
|
+
private readonly orderId: string
|
|
18
|
+
|
|
19
|
+
constructor(orderId: string) {
|
|
20
|
+
super()
|
|
21
|
+
this.orderId = orderId
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getPath(): string {
|
|
25
|
+
return `/orders/${this.orderId}`
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { OrderDetails, orderDetailsSchema } from '../../models'
|
|
5
|
+
|
|
6
|
+
export const getOrderDetailsInputSchema = z.undefined()
|
|
7
|
+
|
|
8
|
+
export const getOrderDetailsResponseSchema = orderDetailsSchema
|
|
9
|
+
export type GetOrderDetailsResponse = OrderDetails
|
|
10
|
+
|
|
11
|
+
export class GetOrderDetails extends AbstractApiRequest<void, GetOrderDetailsResponse> {
|
|
12
|
+
readonly method = 'GET'
|
|
13
|
+
readonly contentType = 'application/json'
|
|
14
|
+
readonly accept = 'application/json'
|
|
15
|
+
readonly inputSchema = getOrderDetailsInputSchema
|
|
16
|
+
readonly outputSchema = getOrderDetailsResponseSchema
|
|
17
|
+
readonly querySchema = undefined
|
|
18
|
+
readonly headersSchema = undefined
|
|
19
|
+
|
|
20
|
+
private readonly orderId: string
|
|
21
|
+
|
|
22
|
+
constructor(orderId: string) {
|
|
23
|
+
super()
|
|
24
|
+
this.orderId = orderId
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getPath(): string {
|
|
28
|
+
return `/orders/${this.orderId}`
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import {
|
|
3
|
+
createPaginatedSchema,
|
|
4
|
+
Paginated,
|
|
5
|
+
responseToPagination,
|
|
6
|
+
} from '@deliverart/sdk-js-global-types'
|
|
7
|
+
import { AxiosResponse } from 'axios'
|
|
8
|
+
import { z } from 'zod'
|
|
9
|
+
|
|
10
|
+
import { Order, orderSchema, OrdersQueryParams, ordersQuerySchema } from '../../models'
|
|
11
|
+
|
|
12
|
+
export const getOrdersQuerySchema = ordersQuerySchema
|
|
13
|
+
export type GetOrdersQueryParams = z.infer<typeof getOrdersQuerySchema>
|
|
14
|
+
|
|
15
|
+
export const getOrdersResponseSchema = createPaginatedSchema(orderSchema)
|
|
16
|
+
export type GetOrdersResponse = z.infer<typeof getOrdersResponseSchema>
|
|
17
|
+
|
|
18
|
+
export const getOrdersInputSchema = z.undefined()
|
|
19
|
+
|
|
20
|
+
export class GetOrders extends AbstractApiRequest<void, GetOrdersResponse, GetOrdersQueryParams> {
|
|
21
|
+
readonly method = 'GET'
|
|
22
|
+
readonly contentType = 'application/json'
|
|
23
|
+
readonly accept = 'application/json'
|
|
24
|
+
|
|
25
|
+
readonly inputSchema = getOrdersInputSchema
|
|
26
|
+
readonly outputSchema = getOrdersResponseSchema
|
|
27
|
+
readonly querySchema = getOrdersQuerySchema
|
|
28
|
+
readonly headersSchema = undefined
|
|
29
|
+
|
|
30
|
+
constructor(options?: { query?: OrdersQueryParams }) {
|
|
31
|
+
super(undefined, options)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getPath(): string {
|
|
35
|
+
return '/orders'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
parseResponse(data: unknown, rawResponse: AxiosResponse): Paginated<Order> {
|
|
39
|
+
const orders = z.array(orderSchema).parse(data)
|
|
40
|
+
return this.validateOutput({ data: orders, pagination: responseToPagination(rawResponse) })
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AbstractApiRequest } from '@deliverart/sdk-js-core'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { OrderDetails, orderDetailsSchema, writableOrderSchema } from '../../models'
|
|
5
|
+
|
|
6
|
+
export const updateOrderInputSchema = writableOrderSchema
|
|
7
|
+
.omit({
|
|
8
|
+
pointOfSale: true,
|
|
9
|
+
type: true,
|
|
10
|
+
source: true,
|
|
11
|
+
partner: true,
|
|
12
|
+
partnerIdentifier: true,
|
|
13
|
+
displayId: true,
|
|
14
|
+
autoAccept: true,
|
|
15
|
+
})
|
|
16
|
+
.partial()
|
|
17
|
+
export type UpdateOrderInput = z.infer<typeof updateOrderInputSchema>
|
|
18
|
+
|
|
19
|
+
export const updateOrderResponseSchema = orderDetailsSchema
|
|
20
|
+
export type UpdateOrderResponse = OrderDetails
|
|
21
|
+
|
|
22
|
+
export class UpdateOrder extends AbstractApiRequest<UpdateOrderInput, UpdateOrderResponse> {
|
|
23
|
+
readonly method = 'PATCH'
|
|
24
|
+
readonly contentType = 'application/merge-patch+json'
|
|
25
|
+
readonly accept = 'application/json'
|
|
26
|
+
|
|
27
|
+
readonly inputSchema = updateOrderInputSchema
|
|
28
|
+
readonly outputSchema = updateOrderResponseSchema
|
|
29
|
+
readonly querySchema = undefined
|
|
30
|
+
readonly headersSchema = undefined
|
|
31
|
+
|
|
32
|
+
private readonly orderId: string
|
|
33
|
+
|
|
34
|
+
constructor(orderId: string, input: UpdateOrderInput) {
|
|
35
|
+
super(input)
|
|
36
|
+
this.orderId = orderId
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getPath(): string {
|
|
40
|
+
return `/orders/${this.orderId}`
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export const orderTypes = ['delivery', 'take_away', 'kitchen'] as const
|
|
4
|
+
export const orderTypeSchema = z.enum(orderTypes)
|
|
5
|
+
export type OrderType = z.infer<typeof orderTypeSchema>
|
|
6
|
+
|
|
7
|
+
export const orderSources = ['application', 'ecommerce', 'other'] as const
|
|
8
|
+
export const orderSourceSchema = z.enum(orderSources)
|
|
9
|
+
export type OrderSource = z.infer<typeof orderSourceSchema>
|
|
10
|
+
|
|
11
|
+
export const orderStatuses = ['pending', 'confirmed', 'rejected'] as const
|
|
12
|
+
export const orderStatusSchema = z.enum(orderStatuses)
|
|
13
|
+
export type OrderStatus = z.infer<typeof orderStatusSchema>
|
|
14
|
+
|
|
15
|
+
export const orderPreparationStatuses = ['to_prepare', 'in_preparation', 'done'] as const
|
|
16
|
+
export const orderPreparationStatusSchema = z.enum(orderPreparationStatuses)
|
|
17
|
+
export type OrderPreparationStatus = z.infer<typeof orderPreparationStatusSchema>
|
|
18
|
+
|
|
19
|
+
export const orderMenuItemActions = ['add', 'remove'] as const
|
|
20
|
+
export const orderMenuItemActionSchema = z.enum(orderMenuItemActions)
|
|
21
|
+
export type OrderMenuItemAction = z.infer<typeof orderMenuItemActionSchema>
|
|
22
|
+
|
|
23
|
+
export const bundleStatuses = ['pending', 'busy', 'broken', 'released'] as const
|
|
24
|
+
export const bundleStatusSchema = z.enum(bundleStatuses)
|
|
25
|
+
export type BundleStatus = z.infer<typeof bundleStatusSchema>
|
|
26
|
+
|
|
27
|
+
export const bundleTypes = ['REGULAR', 'FORCED'] as const
|
|
28
|
+
export const bundleTypeSchema = z.enum(bundleTypes)
|
|
29
|
+
export type BundleType = z.infer<typeof bundleTypeSchema>
|
|
30
|
+
|
|
31
|
+
export const bundleBundleBrokenReasons = ['delivery_removed'] as const
|
|
32
|
+
export const bundleBundleBrokenReasonSchema = z.enum(bundleBundleBrokenReasons)
|
|
33
|
+
export type BundleBundleBrokenReason = z.infer<typeof bundleBundleBrokenReasonSchema>
|
|
34
|
+
|
|
35
|
+
export const orderPathSchema = z
|
|
36
|
+
.string()
|
|
37
|
+
.refine(val => /^\/orders\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val), {
|
|
38
|
+
message: 'Invalid order path format',
|
|
39
|
+
})
|
|
40
|
+
export type OrderPath = z.infer<typeof orderPathSchema>
|
|
41
|
+
|
|
42
|
+
export const orderNullablePathSchema = z
|
|
43
|
+
.string()
|
|
44
|
+
.nullable()
|
|
45
|
+
.refine(
|
|
46
|
+
val => {
|
|
47
|
+
if (!val) return true
|
|
48
|
+
return /^\/orders\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val)
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
message: 'Invalid order path format',
|
|
52
|
+
},
|
|
53
|
+
)
|
|
54
|
+
export type OrderNullablePath = z.infer<typeof orderNullablePathSchema>
|
|
55
|
+
|
|
56
|
+
export const orderMenuItemPathSchema = z
|
|
57
|
+
.string()
|
|
58
|
+
.refine(val => /^\/orders\/menu_items\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val), {
|
|
59
|
+
message: 'Invalid order menu item path format',
|
|
60
|
+
})
|
|
61
|
+
export type OrderMenuItemPath = z.infer<typeof orderMenuItemPathSchema>
|
|
62
|
+
|
|
63
|
+
export const orderMenuItemNullablePathSchema = z
|
|
64
|
+
.string()
|
|
65
|
+
.nullable()
|
|
66
|
+
.refine(
|
|
67
|
+
val => {
|
|
68
|
+
if (!val) return true
|
|
69
|
+
return /^\/orders\/menu_items\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val)
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
message: 'Invalid order menu item path format',
|
|
73
|
+
},
|
|
74
|
+
)
|
|
75
|
+
export type OrderMenuItemNullablePath = z.infer<typeof orderMenuItemNullablePathSchema>
|
|
76
|
+
|
|
77
|
+
export const orderMenuItemModifierPathSchema = z
|
|
78
|
+
.string()
|
|
79
|
+
.refine(val => /^\/orders\/menu_items\/modifiers\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val), {
|
|
80
|
+
message: 'Invalid order menu item modifier path format',
|
|
81
|
+
})
|
|
82
|
+
export type OrderMenuItemModifierPath = z.infer<typeof orderMenuItemModifierPathSchema>
|
|
83
|
+
|
|
84
|
+
export const orderMenuItemModifierNullablePathSchema = z
|
|
85
|
+
.string()
|
|
86
|
+
.nullable()
|
|
87
|
+
.refine(
|
|
88
|
+
val => {
|
|
89
|
+
if (!val) return true
|
|
90
|
+
return /^\/orders\/menu_items\/modifiers\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val)
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
message: 'Invalid order menu item modifier path format',
|
|
94
|
+
},
|
|
95
|
+
)
|
|
96
|
+
export type OrderMenuItemModifierNullablePath = z.infer<
|
|
97
|
+
typeof orderMenuItemModifierNullablePathSchema
|
|
98
|
+
>
|
|
99
|
+
|
|
100
|
+
export const bundlePathSchema = z
|
|
101
|
+
.string()
|
|
102
|
+
.refine(val => /^\/bundles\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val), {
|
|
103
|
+
message: 'Invalid bundle path format',
|
|
104
|
+
})
|
|
105
|
+
export type BundlePath = z.infer<typeof bundlePathSchema>
|
|
106
|
+
|
|
107
|
+
export const bundleNullablePathSchema = z
|
|
108
|
+
.string()
|
|
109
|
+
.nullable()
|
|
110
|
+
.refine(
|
|
111
|
+
val => {
|
|
112
|
+
if (!val) return true
|
|
113
|
+
return /^\/bundles\/[a-z_]+\/[0-9a-fA-F-]{36}$/.test(val)
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
message: 'Invalid bundle path format',
|
|
117
|
+
},
|
|
118
|
+
)
|
|
119
|
+
export type BundleNullablePath = z.infer<typeof bundleNullablePathSchema>
|