@deliverart/sdk-js-customer
v2.10.5
Published
Deliverart JavaScript SDK for Customer and CustomerAddress Management
Downloads
1,315
Readme
@deliverart/sdk-js-customer
Customer and business profile management package for the DeliverArt JavaScript SDK.
Installation
npm install @deliverart/sdk-js-customer @deliverart/sdk-js-coreExported Types
Core Types
Customer- Customer basic informationCustomerDetails- Extended customer with relationsCustomerAddress- Customer delivery addressCustomerBusinessProfile- Business profile for B2B customers
IRI Types
CustomerIri- Customer IRI (/customers/:id)CustomerAddressIri- Customer address IRI (/customer_addresses/:id)CustomerBusinessProfileIri- Business profile IRI (/customer_business_profiles/:id)
Available Requests
Customer Management
CreateCustomer
import { CreateCustomer } from '@deliverart/sdk-js-customer';
const customer = await sdk.call(new CreateCustomer({
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
phoneNumber: '+39123456789',
company: '/companies/123' // Optional
}));Input Parameters:
firstName: string(required) - First namelastName: string(required) - Last nameemail: string(required) - Email addressphoneNumber: string(required) - Phone numbercompany?: string(optional) - Company IRI
GetCustomers
import { GetCustomers } from '@deliverart/sdk-js-customer';
const customers = await sdk.call(new GetCustomers({
query: {
email: '[email protected]',
phoneNumber: '+39123456789',
page: 1
}
}));Query Parameters:
firstName?: string- Filter by first namelastName?: string- Filter by last nameemail?: string- Filter by emailphoneNumber?: string- Filter by phone numbercompany?: string- Filter by company IRIpage?: number- Page number
GetCustomerDetails
import { GetCustomerDetails } from '@deliverart/sdk-js-customer';
const customer = await sdk.call(new GetCustomerDetails('customer-123'));UpdateCustomer
import { UpdateCustomer } from '@deliverart/sdk-js-customer';
const updated = await sdk.call(new UpdateCustomer('customer-123', {
firstName: 'Jane'
}));DeleteCustomer
import { DeleteCustomer } from '@deliverart/sdk-js-customer';
await sdk.call(new DeleteCustomer('customer-123'));Customer Addresses
CreateCustomerAddress
import { CreateCustomerAddress } from '@deliverart/sdk-js-customer';
const address = await sdk.call(new CreateCustomerAddress({
customer: '/customers/123',
street: 'Via Roma 1',
city: 'Milano',
postalCode: '20100',
country: 'IT',
location: {
latitude: 45.464664,
longitude: 9.188540
}
}));Input Parameters:
customer: string(required) - Customer IRIstreet: string(required) - Street addresscity: string(required) - CitypostalCode: string(required) - Postal codecountry: string(required) - Country code (ISO 3166-1 alpha-2)state?: string(optional) - State/regionprovince?: string(optional) - Provincelocation?: { latitude: number, longitude: number }(optional) - GPS coordinates
GetCustomerAddresses
import { GetCustomerAddresses } from '@deliverart/sdk-js-customer';
const addresses = await sdk.call(new GetCustomerAddresses({
query: {
customer: '/customers/123'
}
}));UpdateCustomerAddress
import { UpdateCustomerAddress } from '@deliverart/sdk-js-customer';
const updated = await sdk.call(new UpdateCustomerAddress('address-123', {
street: 'Via Nuova 10'
}));DeleteCustomerAddress
import { DeleteCustomerAddress } from '@deliverart/sdk-js-customer';
await sdk.call(new DeleteCustomerAddress('address-123'));Business Profiles (B2B)
CreateCustomerBusinessProfile
import { CreateCustomerBusinessProfile } from '@deliverart/sdk-js-customer';
const profile = await sdk.call(new CreateCustomerBusinessProfile({
customer: '/customers/123',
businessName: 'Acme Inc',
vat: 'IT12345678901',
taxCode: 'ACME123',
billingAddress: {
street: 'Via Business 1',
city: 'Milano',
postalCode: '20100',
country: 'IT'
},
billingData: {
email: '[email protected]',
pec: '[email protected]'
}
}));Input Parameters:
customer: string(required) - Customer IRIbusinessName: string(required) - Business namevat: string(required) - VAT numbertaxCode?: string(optional) - Tax codebillingAddress: Address(required) - Billing addressbillingData: BillingData(required) - Billing contact information
GetCustomerBusinessProfiles
import { GetCustomerBusinessProfiles } from '@deliverart/sdk-js-customer';
const profiles = await sdk.call(new GetCustomerBusinessProfiles({
query: {
customer: '/customers/123'
}
}));UpdateCustomerBusinessProfile
import { UpdateCustomerBusinessProfile } from '@deliverart/sdk-js-customer';
const updated = await sdk.call(new UpdateCustomerBusinessProfile('profile-123', {
businessName: 'Acme Corporation'
}));DeleteCustomerBusinessProfile
import { DeleteCustomerBusinessProfile } from '@deliverart/sdk-js-customer';
await sdk.call(new DeleteCustomerBusinessProfile('profile-123'));Complete Usage Example
import { sdk } from './lib/sdk';
import {
CreateCustomer,
CreateCustomerAddress,
CreateCustomerBusinessProfile,
GetCustomers
} from '@deliverart/sdk-js-customer';
async function customerWorkflow() {
// Create customer
const customer = await sdk.call(new CreateCustomer({
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
phoneNumber: '+39123456789',
company: '/companies/123'
}));
// Add delivery address
const address = await sdk.call(new CreateCustomerAddress({
customer: `/customers/${customer.id}`,
street: 'Via Roma 1',
city: 'Milano',
postalCode: '20100',
country: 'IT',
location: {
latitude: 45.464664,
longitude: 9.188540
}
}));
// Add business profile (for B2B)
const businessProfile = await sdk.call(new CreateCustomerBusinessProfile({
customer: `/customers/${customer.id}`,
businessName: 'Acme Inc',
vat: 'IT12345678901',
billingAddress: {
street: 'Via Business 1',
city: 'Milano',
postalCode: '20100',
country: 'IT'
},
billingData: {
email: '[email protected]',
pec: '[email protected]'
}
}));
// Search customers
const customers = await sdk.call(new GetCustomers({
query: {
email: '[email protected]'
}
}));
console.log(`Found ${customers.pagination.totalItems} customers`);
}License
MIT
