@deliverart/sdk-js-customer 0.0.0-dev-20260721002647

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/README.md ADDED
@@ -0,0 +1,302 @@
1
+ # @deliverart/sdk-js-customer
2
+
3
+ Customer and business profile management package for the DeliverArt JavaScript SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @deliverart/sdk-js-customer @deliverart/sdk-js-core
9
+ ```
10
+
11
+ ## Exported Types
12
+
13
+ ### Core Types
14
+ - `Customer` - Customer basic information
15
+ - `CustomerDetails` - Extended customer with relations
16
+ - `CustomerAddress` - Customer delivery address
17
+ - `CustomerBusinessProfile` - Business profile for B2B customers
18
+
19
+ ### IRI Types
20
+ - `CustomerIri` - Customer IRI (`/customers/:id`)
21
+ - `CustomerAddressIri` - Customer address IRI (`/customer_addresses/:id`)
22
+ - `CustomerBusinessProfileIri` - Business profile IRI (`/customer_business_profiles/:id`)
23
+
24
+ ## Available Requests
25
+
26
+ ### Customer Management
27
+
28
+ #### CreateCustomer
29
+ ```typescript
30
+ import { CreateCustomer } from '@deliverart/sdk-js-customer';
31
+
32
+ const customer = await sdk.call(new CreateCustomer({
33
+ firstName: 'John',
34
+ lastName: 'Doe',
35
+ email: 'john@example.com',
36
+ phoneNumber: '+39123456789',
37
+ company: '/companies/123' // Optional
38
+ }));
39
+ ```
40
+
41
+ **Input Parameters:**
42
+ - `firstName: string` (required) - First name
43
+ - `lastName: string` (required) - Last name
44
+ - `email: string` (required) - Email address
45
+ - `phoneNumber: string` (required) - Phone number
46
+ - `company?: string` (optional) - Company IRI
47
+
48
+ #### CreateCustomerFromCurrentUser
49
+ ```typescript
50
+ import { CreateCustomerFromCurrentUser } from '@deliverart/sdk-js-customer';
51
+
52
+ const customer = await sdk.call(new CreateCustomerFromCurrentUser({
53
+ pointOfSale: '/point_of_sales/123',
54
+ firstName: 'John',
55
+ lastName: 'Doe',
56
+ email: 'john@example.com',
57
+ phoneNumber: null
58
+ }));
59
+ ```
60
+
61
+ Creates or returns the POS-scoped customer relationship for the authenticated
62
+ consumer user. This is the ecommerce account flow: the Deliverart user remains
63
+ global, while each seller still gets a reliable local `Customer` profile for
64
+ CRM, addresses, stats, and order history.
65
+
66
+ **Input Parameters:**
67
+ - `pointOfSale: string` (required) - Point of sale IRI
68
+ - `firstName: string | null` (required) - First name fallback for the customer profile
69
+ - `lastName: string | null` (required) - Last name fallback for the customer profile
70
+ - `email: string | null` (required) - Email fallback for the customer profile
71
+ - `phoneNumber: string | null` (required) - Phone fallback for the customer profile
72
+
73
+ #### GetCustomers
74
+ ```typescript
75
+ import { GetCustomers } from '@deliverart/sdk-js-customer';
76
+
77
+ const customers = await sdk.call(new GetCustomers({
78
+ query: {
79
+ email: 'john@example.com',
80
+ phoneNumber: '+39123456789',
81
+ page: 1
82
+ }
83
+ }));
84
+ ```
85
+
86
+ **Query Parameters:**
87
+ - `firstName?: string` - Filter by first name
88
+ - `lastName?: string` - Filter by last name
89
+ - `email?: string` - Filter by email
90
+ - `phoneNumber?: string` - Filter by phone number
91
+ - `company?: string` - Filter by company IRI
92
+ - `page?: number` - Page number
93
+
94
+ #### GetCustomerDetails
95
+ ```typescript
96
+ import { GetCustomerDetails } from '@deliverart/sdk-js-customer';
97
+
98
+ const customer = await sdk.call(new GetCustomerDetails('customer-123'));
99
+ ```
100
+
101
+ #### UpdateCustomer
102
+ ```typescript
103
+ import { UpdateCustomer } from '@deliverart/sdk-js-customer';
104
+
105
+ const updated = await sdk.call(new UpdateCustomer('customer-123', {
106
+ firstName: 'Jane'
107
+ }));
108
+ ```
109
+
110
+ #### DeleteCustomer
111
+ ```typescript
112
+ import { DeleteCustomer } from '@deliverart/sdk-js-customer';
113
+
114
+ await sdk.call(new DeleteCustomer('customer-123'));
115
+ ```
116
+
117
+ ---
118
+
119
+ ### Customer Addresses
120
+
121
+ #### CreateCustomerAddress
122
+ ```typescript
123
+ import { CreateCustomerAddress } from '@deliverart/sdk-js-customer';
124
+
125
+ const address = await sdk.call(new CreateCustomerAddress({
126
+ customer: '/customers/123',
127
+ street: 'Via Roma 1',
128
+ city: 'Milano',
129
+ postalCode: '20100',
130
+ country: 'IT',
131
+ location: {
132
+ latitude: 45.464664,
133
+ longitude: 9.188540
134
+ }
135
+ }));
136
+ ```
137
+
138
+ **Input Parameters:**
139
+ - `customer: string` (required) - Customer IRI
140
+ - `street: string` (required) - Street address
141
+ - `city: string` (required) - City
142
+ - `postalCode: string` (required) - Postal code
143
+ - `country: string` (required) - Country code (ISO 3166-1 alpha-2)
144
+ - `state?: string` (optional) - State/region
145
+ - `province?: string` (optional) - Province
146
+ - `location?: { latitude: number, longitude: number }` (optional) - GPS coordinates
147
+
148
+ #### GetCustomerAddresses
149
+ ```typescript
150
+ import { GetCustomerAddresses } from '@deliverart/sdk-js-customer';
151
+
152
+ const addresses = await sdk.call(new GetCustomerAddresses({
153
+ query: {
154
+ customer: '/customers/123'
155
+ }
156
+ }));
157
+ ```
158
+
159
+ #### UpdateCustomerAddress
160
+ ```typescript
161
+ import { UpdateCustomerAddress } from '@deliverart/sdk-js-customer';
162
+
163
+ const updated = await sdk.call(new UpdateCustomerAddress('address-123', {
164
+ street: 'Via Nuova 10'
165
+ }));
166
+ ```
167
+
168
+ #### DeleteCustomerAddress
169
+ ```typescript
170
+ import { DeleteCustomerAddress } from '@deliverart/sdk-js-customer';
171
+
172
+ await sdk.call(new DeleteCustomerAddress('address-123'));
173
+ ```
174
+
175
+ ---
176
+
177
+ ### Business Profiles (B2B)
178
+
179
+ #### CreateCustomerBusinessProfile
180
+ ```typescript
181
+ import { CreateCustomerBusinessProfile } from '@deliverart/sdk-js-customer';
182
+
183
+ const profile = await sdk.call(new CreateCustomerBusinessProfile({
184
+ customer: '/customers/123',
185
+ businessName: 'Acme Inc',
186
+ vat: 'IT12345678901',
187
+ taxCode: 'ACME123',
188
+ billingAddress: {
189
+ street: 'Via Business 1',
190
+ city: 'Milano',
191
+ postalCode: '20100',
192
+ country: 'IT'
193
+ },
194
+ billingData: {
195
+ email: 'billing@acme.com',
196
+ pec: 'acme@pec.it'
197
+ }
198
+ }));
199
+ ```
200
+
201
+ **Input Parameters:**
202
+ - `customer: string` (required) - Customer IRI
203
+ - `businessName: string` (required) - Business name
204
+ - `vat: string` (required) - VAT number
205
+ - `taxCode?: string` (optional) - Tax code
206
+ - `billingAddress: Address` (required) - Billing address
207
+ - `billingData: BillingData` (required) - Billing contact information
208
+
209
+ #### GetCustomerBusinessProfiles
210
+ ```typescript
211
+ import { GetCustomerBusinessProfiles } from '@deliverart/sdk-js-customer';
212
+
213
+ const profiles = await sdk.call(new GetCustomerBusinessProfiles({
214
+ query: {
215
+ customer: '/customers/123'
216
+ }
217
+ }));
218
+ ```
219
+
220
+ #### UpdateCustomerBusinessProfile
221
+ ```typescript
222
+ import { UpdateCustomerBusinessProfile } from '@deliverart/sdk-js-customer';
223
+
224
+ const updated = await sdk.call(new UpdateCustomerBusinessProfile('profile-123', {
225
+ businessName: 'Acme Corporation'
226
+ }));
227
+ ```
228
+
229
+ #### DeleteCustomerBusinessProfile
230
+ ```typescript
231
+ import { DeleteCustomerBusinessProfile } from '@deliverart/sdk-js-customer';
232
+
233
+ await sdk.call(new DeleteCustomerBusinessProfile('profile-123'));
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Complete Usage Example
239
+
240
+ ```typescript
241
+ import { sdk } from './lib/sdk';
242
+ import {
243
+ CreateCustomer,
244
+ CreateCustomerAddress,
245
+ CreateCustomerBusinessProfile,
246
+ GetCustomers
247
+ } from '@deliverart/sdk-js-customer';
248
+
249
+ async function customerWorkflow() {
250
+ // Create customer
251
+ const customer = await sdk.call(new CreateCustomer({
252
+ firstName: 'John',
253
+ lastName: 'Doe',
254
+ email: 'john@example.com',
255
+ phoneNumber: '+39123456789',
256
+ company: '/companies/123'
257
+ }));
258
+
259
+ // Add delivery address
260
+ const address = await sdk.call(new CreateCustomerAddress({
261
+ customer: `/customers/${customer.id}`,
262
+ street: 'Via Roma 1',
263
+ city: 'Milano',
264
+ postalCode: '20100',
265
+ country: 'IT',
266
+ location: {
267
+ latitude: 45.464664,
268
+ longitude: 9.188540
269
+ }
270
+ }));
271
+
272
+ // Add business profile (for B2B)
273
+ const businessProfile = await sdk.call(new CreateCustomerBusinessProfile({
274
+ customer: `/customers/${customer.id}`,
275
+ businessName: 'Acme Inc',
276
+ vat: 'IT12345678901',
277
+ billingAddress: {
278
+ street: 'Via Business 1',
279
+ city: 'Milano',
280
+ postalCode: '20100',
281
+ country: 'IT'
282
+ },
283
+ billingData: {
284
+ email: 'billing@acme.com',
285
+ pec: 'acme@pec.it'
286
+ }
287
+ }));
288
+
289
+ // Search customers
290
+ const customers = await sdk.call(new GetCustomers({
291
+ query: {
292
+ email: 'john@example.com'
293
+ }
294
+ }));
295
+
296
+ console.log(`Found ${customers.pagination.totalItems} customers`);
297
+ }
298
+ ```
299
+
300
+ ## License
301
+
302
+ MIT