@deliverart/sdk-js-customer 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.
Files changed (36) hide show
  1. package/.changeset/config.json +11 -0
  2. package/.github/workflows/workflow.yml +47 -0
  3. package/.prettierrc +7 -0
  4. package/CHANGELOG.md +37 -0
  5. package/README.md +3 -0
  6. package/dist/index.cjs +747 -0
  7. package/dist/index.d.cts +4485 -0
  8. package/dist/index.d.ts +4485 -0
  9. package/dist/index.js +667 -0
  10. package/eslint.config.js +41 -0
  11. package/package.json +48 -0
  12. package/src/index.ts +3 -0
  13. package/src/models.ts +102 -0
  14. package/src/requests/customer-addresses/CreateCustomerAddress.ts +36 -0
  15. package/src/requests/customer-addresses/DeleteCustomerAddress.ts +27 -0
  16. package/src/requests/customer-addresses/GetCustomerAddressDetails.ts +33 -0
  17. package/src/requests/customer-addresses/GetCustomerAddresses.ts +57 -0
  18. package/src/requests/customer-addresses/GetCustomerAddressesForCustomer.ts +55 -0
  19. package/src/requests/customer-addresses/UpdateCustomerAddress.ts +39 -0
  20. package/src/requests/customer-addresses/index.ts +6 -0
  21. package/src/requests/customer-business-profiles/CreateCustomerBusinessProfile.ts +39 -0
  22. package/src/requests/customer-business-profiles/DeleteCustomerBusinessProfile.ts +27 -0
  23. package/src/requests/customer-business-profiles/GetCustomerBusinessProfileDetails.ts +33 -0
  24. package/src/requests/customer-business-profiles/GetCustomerBusinessProfiles.ts +67 -0
  25. package/src/requests/customer-business-profiles/GetCustomerBusinessProfilesForCustomer.ts +61 -0
  26. package/src/requests/customer-business-profiles/UpdateCustomerBusinessProfile.ts +42 -0
  27. package/src/requests/customer-business-profiles/index.ts +6 -0
  28. package/src/requests/customers/CreateCustomer.ts +32 -0
  29. package/src/requests/customers/DeleteCustomer.ts +27 -0
  30. package/src/requests/customers/GetCustomerDetails.ts +30 -0
  31. package/src/requests/customers/GetCustomers.ts +72 -0
  32. package/src/requests/customers/UpdateCustomer.ts +35 -0
  33. package/src/requests/customers/index.ts +5 -0
  34. package/src/requests/index.ts +3 -0
  35. package/src/types.ts +66 -0
  36. package/tsconfig.json +15 -0
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@deliverart/sdk-js-customer",
3
+ "description": "Deliverart JavaScript SDK for Customer and CustomerAddress Management",
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs"
12
+ }
13
+ },
14
+ "dependencies": {
15
+ "@deliverart/sdk-js-core": "0.1.3",
16
+ "@deliverart/sdk-js-global-types": "0.0.13",
17
+ "@deliverart/sdk-js-point-of-sale": "0.0.4",
18
+ "@deliverart/sdk-js-user": "0.2.5",
19
+ "axios": "1.9.0",
20
+ "zod": "3.25.67"
21
+ },
22
+ "devDependencies": {
23
+ "@changesets/cli": "^2.29.4",
24
+ "@eslint/js": "9.28.0",
25
+ "@types/node": "22.15.30",
26
+ "@typescript-eslint/eslint-plugin": "8.33.1",
27
+ "@typescript-eslint/parser": "8.33.1",
28
+ "eslint": "9.28.0",
29
+ "eslint-config-prettier": "10.1.5",
30
+ "eslint-plugin-simple-import-sort": "12.1.1",
31
+ "prettier": "3.5.3",
32
+ "tsup": "8.5.0",
33
+ "typescript": "5.8.3"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "scripts": {
39
+ "build": "tsup src/index.ts --dts --format esm,cjs",
40
+ "dev": "tsup src/index.ts --dts --watch",
41
+ "lint": "eslint .",
42
+ "lint:fix": "eslint . --fix",
43
+ "prettier": "prettier --check .",
44
+ "prettier:fix": "prettier --write .",
45
+ "version": "@changesets/cli version",
46
+ "release": "@changesets/cli publish"
47
+ }
48
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './models'
2
+ export * from './requests'
3
+ export * from './types'
package/src/models.ts ADDED
@@ -0,0 +1,102 @@
1
+ import {
2
+ addressSchema,
3
+ billingDataSchema,
4
+ datetimeSchema,
5
+ locationSchema,
6
+ } from '@deliverart/sdk-js-global-types'
7
+ import { pointOfSaleNullablePathSchema } from '@deliverart/sdk-js-point-of-sale'
8
+ import { userNullablePathSchema } from '@deliverart/sdk-js-user'
9
+ import { z } from 'zod'
10
+
11
+ import {
12
+ customerAddressPathSchema,
13
+ customerBusinessProfilePathSchema,
14
+ customerPathSchema,
15
+ } from './types'
16
+
17
+ export const customerSchema = z.object({
18
+ id: z.string(),
19
+ firstName: z.string().nullable(),
20
+ lastName: z.string().nullable(),
21
+ email: z.string().email().nullable(),
22
+ phoneNumber: z.string().nullable(),
23
+ hasBusinessProfiles: z.boolean(),
24
+ hasAddresses: z.boolean(),
25
+ ordersPlaced: z.number(),
26
+ totalSpent: z.number(),
27
+ createdAt: datetimeSchema,
28
+ updatedAt: datetimeSchema,
29
+ })
30
+ export type Customer = z.infer<typeof customerSchema>
31
+
32
+ export const customerDetailsSchema = customerSchema.extend({
33
+ pointOfSale: pointOfSaleNullablePathSchema,
34
+ owner: userNullablePathSchema,
35
+ addresses: z.array(customerAddressPathSchema),
36
+ businessProfiles: z.array(customerBusinessProfilePathSchema),
37
+ })
38
+ export type CustomerDetails = z.infer<typeof customerDetailsSchema>
39
+
40
+ export const writableCreateCustomerSchema = customerDetailsSchema.pick({
41
+ pointOfSale: true,
42
+ firstName: true,
43
+ lastName: true,
44
+ email: true,
45
+ phoneNumber: true,
46
+ })
47
+ export const writableCustomerSchema = writableCreateCustomerSchema.omit({
48
+ pointOfSale: true,
49
+ })
50
+
51
+ export const customerAddressSchema = z.object({
52
+ id: z.string(),
53
+ address: addressSchema,
54
+ location: locationSchema,
55
+ createdAt: datetimeSchema,
56
+ updatedAt: datetimeSchema,
57
+ })
58
+ export type CustomerAddress = z.infer<typeof customerAddressSchema>
59
+
60
+ export const customerAddressDetailsSchema = customerAddressSchema.extend({
61
+ customer: customerPathSchema,
62
+ })
63
+ export type CustomerAddressDetails = z.infer<typeof customerAddressDetailsSchema>
64
+
65
+ export const writableCreateCustomerAddressSchema = customerAddressDetailsSchema.pick({
66
+ customer: true,
67
+ address: true,
68
+ })
69
+ export const writableCustomerAddressSchema = writableCreateCustomerAddressSchema.omit({
70
+ customer: true,
71
+ })
72
+
73
+ export const customerBusinessProfileSchema = z.object({
74
+ id: z.string(),
75
+ businessName: z.string(),
76
+ vat: z.string(),
77
+ taxCode: z.string(),
78
+ billingAddress: addressSchema,
79
+ billingData: billingDataSchema,
80
+ createdAt: datetimeSchema,
81
+ updatedAt: datetimeSchema,
82
+ })
83
+ export type CustomerBusinessProfile = z.infer<typeof customerBusinessProfileSchema>
84
+
85
+ export const customerBusinessProfileDetailsSchema = customerBusinessProfileSchema.extend({
86
+ customer: customerPathSchema,
87
+ })
88
+ export type CustomerBusinessProfileDetails = z.infer<typeof customerBusinessProfileDetailsSchema>
89
+
90
+ export const writableCreateCustomerBusinessProfileSchema =
91
+ customerBusinessProfileDetailsSchema.pick({
92
+ customer: true,
93
+ businessName: true,
94
+ vat: true,
95
+ taxCode: true,
96
+ billingAddress: true,
97
+ billingData: true,
98
+ })
99
+ export const writableCustomerBusinessProfileSchema =
100
+ writableCreateCustomerBusinessProfileSchema.omit({
101
+ customer: true,
102
+ })
@@ -0,0 +1,36 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ import {
5
+ CustomerAddressDetails,
6
+ customerAddressDetailsSchema,
7
+ writableCreateCustomerAddressSchema,
8
+ } from '../../models'
9
+
10
+ export const createCustomerAddressInputSchema = writableCreateCustomerAddressSchema.required()
11
+ export type CreateCustomerAddressInput = z.infer<typeof createCustomerAddressInputSchema>
12
+
13
+ export const createCustomerAddressResponseSchema = customerAddressDetailsSchema
14
+ export type CreateCustomerAddressResponse = CustomerAddressDetails
15
+
16
+ export class CreateCustomerAddress extends AbstractApiRequest<
17
+ CreateCustomerAddressInput,
18
+ CreateCustomerAddressResponse
19
+ > {
20
+ readonly method = 'POST'
21
+ readonly contentType = 'application/json'
22
+ readonly accept = 'application/json'
23
+
24
+ readonly inputSchema = createCustomerAddressInputSchema
25
+ readonly outputSchema = createCustomerAddressResponseSchema
26
+ readonly querySchema = undefined
27
+ readonly headersSchema = undefined
28
+
29
+ constructor(input: CreateCustomerAddressInput) {
30
+ super(input)
31
+ }
32
+
33
+ getPath(): string {
34
+ return '/customers/addresses'
35
+ }
36
+ }
@@ -0,0 +1,27 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ export const deleteCustomerAddressInputSchema = z.undefined()
5
+ export const deleteCustomerAddressResponseSchema = z.undefined()
6
+
7
+ export class DeleteCustomerAddress extends AbstractApiRequest<void, void> {
8
+ readonly method = 'DELETE'
9
+ readonly contentType = 'application/json'
10
+ readonly accept = 'application/json'
11
+
12
+ readonly inputSchema = deleteCustomerAddressInputSchema
13
+ readonly outputSchema = deleteCustomerAddressResponseSchema
14
+ readonly querySchema = undefined
15
+ readonly headersSchema = undefined
16
+
17
+ private readonly customerAddressId: string
18
+
19
+ constructor(customerAddressId: string) {
20
+ super()
21
+ this.customerAddressId = customerAddressId
22
+ }
23
+
24
+ getPath(): string {
25
+ return `/customers/addresses/${this.customerAddressId}`
26
+ }
27
+ }
@@ -0,0 +1,33 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ import { CustomerAddressDetails, customerAddressDetailsSchema } from '../../models'
5
+
6
+ export const getCustomerAddressDetailsInputSchema = z.undefined()
7
+
8
+ export const getCustomerAddressDetailsResponseSchema = customerAddressDetailsSchema
9
+ export type GetCustomerAddressDetailsResponse = CustomerAddressDetails
10
+
11
+ export class GetCustomerAddressDetails extends AbstractApiRequest<
12
+ void,
13
+ GetCustomerAddressDetailsResponse
14
+ > {
15
+ readonly method = 'GET'
16
+ readonly contentType = 'application/json'
17
+ readonly accept = 'application/json'
18
+ readonly inputSchema = getCustomerAddressDetailsInputSchema
19
+ readonly outputSchema = getCustomerAddressDetailsResponseSchema
20
+ readonly querySchema = undefined
21
+ readonly headersSchema = undefined
22
+
23
+ private readonly customerAddressId: string
24
+
25
+ constructor(customerAddressId: string) {
26
+ super()
27
+ this.customerAddressId = customerAddressId
28
+ }
29
+
30
+ getPath(): string {
31
+ return `/customers/addresses/${this.customerAddressId}`
32
+ }
33
+ }
@@ -0,0 +1,57 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import {
3
+ createPaginatedSchema,
4
+ Paginated,
5
+ responseToPagination,
6
+ sortDirSchema,
7
+ timestampsFilterSchema,
8
+ } from '@deliverart/sdk-js-global-types'
9
+ import { AxiosResponse } from 'axios'
10
+ import { z } from 'zod'
11
+
12
+ import { CustomerAddress, customerAddressSchema } from '../../models'
13
+
14
+ export const getCustomerAddressesQuerySchema = z
15
+ .object({
16
+ 'order[createdAt]': sortDirSchema.optional(),
17
+ 'order[updatedAt]': sortDirSchema.optional(),
18
+ page: z.coerce.number().optional(),
19
+ })
20
+ .merge(timestampsFilterSchema)
21
+ export type GetCustomerAddressesQueryParams = z.infer<typeof getCustomerAddressesQuerySchema>
22
+
23
+ export const getCustomerAddressesResponseSchema = createPaginatedSchema(customerAddressSchema)
24
+ export type GetCustomerAddressesResponse = z.infer<typeof getCustomerAddressesResponseSchema>
25
+
26
+ export const getCustomerAddressesInputSchema = z.undefined()
27
+
28
+ export class GetCustomerAddresses extends AbstractApiRequest<
29
+ void,
30
+ GetCustomerAddressesResponse,
31
+ GetCustomerAddressesQueryParams
32
+ > {
33
+ readonly method = 'GET'
34
+ readonly contentType = 'application/json'
35
+ readonly accept = 'application/json'
36
+
37
+ readonly inputSchema = getCustomerAddressesInputSchema
38
+ readonly outputSchema = getCustomerAddressesResponseSchema
39
+ readonly querySchema = getCustomerAddressesQuerySchema
40
+ readonly headersSchema = undefined
41
+
42
+ constructor(options?: { query?: GetCustomerAddressesQueryParams }) {
43
+ super(undefined, options)
44
+ }
45
+
46
+ getPath(): string {
47
+ return '/customers/addresses'
48
+ }
49
+
50
+ parseResponse(data: unknown, rawResponse: AxiosResponse): Paginated<CustomerAddress> {
51
+ const customerAddresses = z.array(customerAddressSchema).parse(data)
52
+ return this.validateOutput({
53
+ data: customerAddresses,
54
+ pagination: responseToPagination(rawResponse),
55
+ })
56
+ }
57
+ }
@@ -0,0 +1,55 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { sortDirSchema, timestampsFilterSchema } from '@deliverart/sdk-js-global-types'
3
+ import { z } from 'zod'
4
+
5
+ import { CustomerAddress, customerAddressSchema } from '../../models'
6
+
7
+ export const getCustomerAddressesForCustomerQuerySchema = z
8
+ .object({
9
+ 'order[createdAt]': sortDirSchema.optional(),
10
+ 'order[updatedAt]': sortDirSchema.optional(),
11
+ })
12
+ .merge(timestampsFilterSchema)
13
+ export type GetCustomerAddressesForCustomerQueryParams = z.infer<
14
+ typeof getCustomerAddressesForCustomerQuerySchema
15
+ >
16
+
17
+ export const getCustomerAddressesForCustomerResponseSchema = z.array(customerAddressSchema)
18
+ export type GetCustomerAddressesForCustomerResponse = z.infer<
19
+ typeof getCustomerAddressesForCustomerResponseSchema
20
+ >
21
+
22
+ export const getCustomerAddressesForCustomerInputSchema = z.undefined()
23
+
24
+ export class GetCustomerAddressesForCustomer extends AbstractApiRequest<
25
+ void,
26
+ GetCustomerAddressesForCustomerResponse,
27
+ GetCustomerAddressesForCustomerQueryParams
28
+ > {
29
+ readonly method = 'GET'
30
+ readonly contentType = 'application/json'
31
+ readonly accept = 'application/json'
32
+
33
+ readonly inputSchema = getCustomerAddressesForCustomerInputSchema
34
+ readonly outputSchema = getCustomerAddressesForCustomerResponseSchema
35
+ readonly querySchema = getCustomerAddressesForCustomerQuerySchema
36
+ readonly headersSchema = undefined
37
+
38
+ private readonly customerId: string
39
+
40
+ constructor(
41
+ customerId: string,
42
+ options?: { query?: GetCustomerAddressesForCustomerQueryParams },
43
+ ) {
44
+ super(undefined, options)
45
+ this.customerId = customerId
46
+ }
47
+
48
+ getPath(): string {
49
+ return `/customers/${this.customerId}/addresses`
50
+ }
51
+
52
+ parseResponse(data: unknown): CustomerAddress[] {
53
+ return z.array(customerAddressSchema).parse(data)
54
+ }
55
+ }
@@ -0,0 +1,39 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ import {
5
+ CustomerAddressDetails,
6
+ customerAddressDetailsSchema,
7
+ writableCustomerAddressSchema,
8
+ } from '../../models'
9
+
10
+ export const updateCustomerAddressInputSchema = writableCustomerAddressSchema.partial()
11
+ export type UpdateCustomerAddressInput = z.infer<typeof updateCustomerAddressInputSchema>
12
+
13
+ export const updateCustomerAddressResponseSchema = customerAddressDetailsSchema
14
+ export type UpdateCustomerAddressResponse = CustomerAddressDetails
15
+
16
+ export class UpdateCustomerAddress extends AbstractApiRequest<
17
+ UpdateCustomerAddressInput,
18
+ UpdateCustomerAddressResponse
19
+ > {
20
+ readonly method = 'PATCH'
21
+ readonly contentType = 'application/merge-patch+json'
22
+ readonly accept = 'application/json'
23
+
24
+ readonly inputSchema = updateCustomerAddressInputSchema
25
+ readonly outputSchema = updateCustomerAddressResponseSchema
26
+ readonly querySchema = undefined
27
+ readonly headersSchema = undefined
28
+
29
+ private readonly customerId: string
30
+
31
+ constructor(customerId: string, input: UpdateCustomerAddressInput) {
32
+ super(input)
33
+ this.customerId = customerId
34
+ }
35
+
36
+ getPath(): string {
37
+ return `/customers/addresses/${this.customerId}`
38
+ }
39
+ }
@@ -0,0 +1,6 @@
1
+ export * from './CreateCustomerAddress'
2
+ export * from './DeleteCustomerAddress'
3
+ export * from './GetCustomerAddressDetails'
4
+ export * from './GetCustomerAddresses'
5
+ export * from './GetCustomerAddressesForCustomer'
6
+ export * from './UpdateCustomerAddress'
@@ -0,0 +1,39 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ import {
5
+ CustomerBusinessProfileDetails,
6
+ customerBusinessProfileDetailsSchema,
7
+ writableCreateCustomerBusinessProfileSchema,
8
+ } from '../../models'
9
+
10
+ export const createCustomerBusinessProfileInputSchema =
11
+ writableCreateCustomerBusinessProfileSchema.required()
12
+ export type CreateCustomerBusinessProfileInput = z.infer<
13
+ typeof createCustomerBusinessProfileInputSchema
14
+ >
15
+
16
+ export const createCustomerBusinessProfileResponseSchema = customerBusinessProfileDetailsSchema
17
+ export type CreateCustomerBusinessProfileResponse = CustomerBusinessProfileDetails
18
+
19
+ export class CreateCustomerBusinessProfile extends AbstractApiRequest<
20
+ CreateCustomerBusinessProfileInput,
21
+ CreateCustomerBusinessProfileResponse
22
+ > {
23
+ readonly method = 'POST'
24
+ readonly contentType = 'application/json'
25
+ readonly accept = 'application/json'
26
+
27
+ readonly inputSchema = createCustomerBusinessProfileInputSchema
28
+ readonly outputSchema = createCustomerBusinessProfileResponseSchema
29
+ readonly querySchema = undefined
30
+ readonly headersSchema = undefined
31
+
32
+ constructor(input: CreateCustomerBusinessProfileInput) {
33
+ super(input)
34
+ }
35
+
36
+ getPath(): string {
37
+ return '/customers/business_profiles'
38
+ }
39
+ }
@@ -0,0 +1,27 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ export const deleteCustomerBusinessProfileInputSchema = z.undefined()
5
+ export const deleteCustomerBusinessProfileResponseSchema = z.undefined()
6
+
7
+ export class DeleteCustomerBusinessProfile extends AbstractApiRequest<void, void> {
8
+ readonly method = 'DELETE'
9
+ readonly contentType = 'application/json'
10
+ readonly accept = 'application/json'
11
+
12
+ readonly inputSchema = deleteCustomerBusinessProfileInputSchema
13
+ readonly outputSchema = deleteCustomerBusinessProfileResponseSchema
14
+ readonly querySchema = undefined
15
+ readonly headersSchema = undefined
16
+
17
+ private readonly customerBusinessProfileId: string
18
+
19
+ constructor(customerBusinessProfileId: string) {
20
+ super()
21
+ this.customerBusinessProfileId = customerBusinessProfileId
22
+ }
23
+
24
+ getPath(): string {
25
+ return `/customers/business_profiles/${this.customerBusinessProfileId}`
26
+ }
27
+ }
@@ -0,0 +1,33 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ import { CustomerBusinessProfileDetails, customerBusinessProfileDetailsSchema } from '../../models'
5
+
6
+ export const getCustomerBusinessProfileDetailsInputSchema = z.undefined()
7
+
8
+ export const getCustomerBusinessProfileDetailsResponseSchema = customerBusinessProfileDetailsSchema
9
+ export type GetCustomerBusinessProfileDetailsResponse = CustomerBusinessProfileDetails
10
+
11
+ export class GetCustomerBusinessProfileDetails extends AbstractApiRequest<
12
+ void,
13
+ GetCustomerBusinessProfileDetailsResponse
14
+ > {
15
+ readonly method = 'GET'
16
+ readonly contentType = 'application/json'
17
+ readonly accept = 'application/json'
18
+ readonly inputSchema = getCustomerBusinessProfileDetailsInputSchema
19
+ readonly outputSchema = getCustomerBusinessProfileDetailsResponseSchema
20
+ readonly querySchema = undefined
21
+ readonly headersSchema = undefined
22
+
23
+ private readonly customerBusinessProfileId: string
24
+
25
+ constructor(customerBusinessProfileId: string) {
26
+ super()
27
+ this.customerBusinessProfileId = customerBusinessProfileId
28
+ }
29
+
30
+ getPath(): string {
31
+ return `/customers/business_profiles/${this.customerBusinessProfileId}`
32
+ }
33
+ }
@@ -0,0 +1,67 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import {
3
+ createPaginatedSchema,
4
+ Paginated,
5
+ responseToPagination,
6
+ sortDirSchema,
7
+ timestampsFilterSchema,
8
+ } from '@deliverart/sdk-js-global-types'
9
+ import { AxiosResponse } from 'axios'
10
+ import { z } from 'zod'
11
+
12
+ import { CustomerBusinessProfile, customerBusinessProfileSchema } from '../../models'
13
+
14
+ export const getCustomerBusinessProfilesQuerySchema = z
15
+ .object({
16
+ 'order[businessName]': sortDirSchema.optional(),
17
+ 'order[createdAt]': sortDirSchema.optional(),
18
+ 'order[updatedAt]': sortDirSchema.optional(),
19
+ businessName: z.string().optional(),
20
+ vat: z.string().optional(),
21
+ taxCode: z.string().optional(),
22
+ page: z.coerce.number().optional(),
23
+ })
24
+ .merge(timestampsFilterSchema)
25
+ export type GetCustomerBusinessProfilesQueryParams = z.infer<
26
+ typeof getCustomerBusinessProfilesQuerySchema
27
+ >
28
+
29
+ export const getCustomerBusinessProfilesResponseSchema = createPaginatedSchema(
30
+ customerBusinessProfileSchema,
31
+ )
32
+ export type GetCustomerBusinessProfilesResponse = z.infer<
33
+ typeof getCustomerBusinessProfilesResponseSchema
34
+ >
35
+
36
+ export const getCustomerBusinessProfilesInputSchema = z.undefined()
37
+
38
+ export class GetCustomerBusinessProfiles extends AbstractApiRequest<
39
+ void,
40
+ GetCustomerBusinessProfilesResponse,
41
+ GetCustomerBusinessProfilesQueryParams
42
+ > {
43
+ readonly method = 'GET'
44
+ readonly contentType = 'application/json'
45
+ readonly accept = 'application/json'
46
+
47
+ readonly inputSchema = getCustomerBusinessProfilesInputSchema
48
+ readonly outputSchema = getCustomerBusinessProfilesResponseSchema
49
+ readonly querySchema = getCustomerBusinessProfilesQuerySchema
50
+ readonly headersSchema = undefined
51
+
52
+ constructor(options?: { query?: GetCustomerBusinessProfilesQueryParams }) {
53
+ super(undefined, options)
54
+ }
55
+
56
+ getPath(): string {
57
+ return '/customers/business_profiles'
58
+ }
59
+
60
+ parseResponse(data: unknown, rawResponse: AxiosResponse): Paginated<CustomerBusinessProfile> {
61
+ const customerBusinessProfiles = z.array(customerBusinessProfileSchema).parse(data)
62
+ return this.validateOutput({
63
+ data: customerBusinessProfiles,
64
+ pagination: responseToPagination(rawResponse),
65
+ })
66
+ }
67
+ }
@@ -0,0 +1,61 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { sortDirSchema, timestampsFilterSchema } from '@deliverart/sdk-js-global-types'
3
+ import { z } from 'zod'
4
+
5
+ import { CustomerBusinessProfile, customerBusinessProfileSchema } from '../../models'
6
+
7
+ export const getCustomerBusinessProfilesForCustomerQuerySchema = z
8
+ .object({
9
+ 'order[businessName]': sortDirSchema.optional(),
10
+ 'order[createdAt]': sortDirSchema.optional(),
11
+ 'order[updatedAt]': sortDirSchema.optional(),
12
+ businessName: z.string().optional(),
13
+ vat: z.string().optional(),
14
+ taxCode: z.string().optional(),
15
+ })
16
+ .merge(timestampsFilterSchema)
17
+ export type GetCustomerBusinessProfilesForCustomerQueryParams = z.infer<
18
+ typeof getCustomerBusinessProfilesForCustomerQuerySchema
19
+ >
20
+
21
+ export const getCustomerBusinessProfilesForCustomerResponseSchema = z.array(
22
+ customerBusinessProfileSchema,
23
+ )
24
+ export type GetCustomerBusinessProfilesForCustomerResponse = z.infer<
25
+ typeof getCustomerBusinessProfilesForCustomerResponseSchema
26
+ >
27
+
28
+ export const getCustomerBusinessProfilesForCustomerInputSchema = z.undefined()
29
+
30
+ export class GetCustomerBusinessProfilesForCustomer extends AbstractApiRequest<
31
+ void,
32
+ GetCustomerBusinessProfilesForCustomerResponse,
33
+ GetCustomerBusinessProfilesForCustomerQueryParams
34
+ > {
35
+ readonly method = 'GET'
36
+ readonly contentType = 'application/json'
37
+ readonly accept = 'application/json'
38
+
39
+ readonly inputSchema = getCustomerBusinessProfilesForCustomerInputSchema
40
+ readonly outputSchema = getCustomerBusinessProfilesForCustomerResponseSchema
41
+ readonly querySchema = getCustomerBusinessProfilesForCustomerQuerySchema
42
+ readonly headersSchema = undefined
43
+
44
+ private readonly customerId: string
45
+
46
+ constructor(
47
+ customerId: string,
48
+ options?: { query?: GetCustomerBusinessProfilesForCustomerQueryParams },
49
+ ) {
50
+ super(undefined, options)
51
+ this.customerId = customerId
52
+ }
53
+
54
+ getPath(): string {
55
+ return `/customers/${this.customerId}/business_profiles`
56
+ }
57
+
58
+ parseResponse(data: unknown): CustomerBusinessProfile[] {
59
+ return z.array(customerBusinessProfileSchema).parse(data)
60
+ }
61
+ }