@ deliverart/ sdk-js- 客户
交付艺术JavaScript SDK的客户和业务简介管理软件包.
安装
npm install @deliverart/sdk-js-customer @deliverart/sdk-js-core
导出类型
核心类型
Customer- 客户基本信息CustomerDetails- 有关系的扩展客户CustomerAddress- 客户交货地址CustomerBusinessProfile- B2B客户的业务概况
IRI 类型
CustomerIri- 客户IRI(/customers/:id(中文(简体) )CustomerAddressIri- 客户地址IRI(/customer_addresses/:id(中文(简体) )CustomerBusinessProfileIri- 企业概况/customer_business_profiles/:id(中文(简体) )
可用请求
客户管理
创建客户端
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
}));
输入参数:
firstName: string(必须) - 姓名lastName: string(必须) - 姓email: string(需要) - 电子邮件地址phoneNumber: string(需要) - 电话号码company?: string(可选) - 公司IRI
从当前用户创建客户端
import { CreateCustomerFromCurrentUser } from '@deliverart/sdk-js-customer';
const customer = await sdk.call(new CreateCustomerFromCurrentUser({
pointOfSale: '/point_of_sales/123',
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
phoneNumber: null
}));
创建或返回已验证的 POS 扫描客户关系
消费用户. 这是电子商务账户流: 交付端用户仍然
在全球范围,而每个销售商仍然得到可靠的本地 Customer 配置图
CRM,地址,统计和订单历史.
输入参数:
pointOfSale: string(需要) - 销售点firstName: string | null(需要) - 客户简介的首字母回落lastName: string | null(需要) - 客户简介的后名email: string | null(需要) - 客户简介的电子邮件倒置phoneNumber: string | null(需要) - 客户简介电话故障
获取客户
import { GetCustomers } from '@deliverart/sdk-js-customer';
const customers = await sdk.call(new GetCustomers({
query: {
email: '[email protected]',
phoneNumber: '+39123456789',
page: 1
}
}));
查询参数:
firstName?: string- 由名字过滤lastName?: string- 按姓氏过滤email?: string- 通过电子邮件过滤phoneNumber?: string- 按电话号码过滤company?: string- 由IRI公司过滤page?: number- 页号
获取客户端
import { GetCustomerDetails } from '@deliverart/sdk-js-customer';
const customer = await sdk.call(new GetCustomerDetails('customer-123'));
更新客户端
import { UpdateCustomer } from '@deliverart/sdk-js-customer';
const updated = await sdk.call(new UpdateCustomer('customer-123', {
firstName: 'Jane'
}));
删除客户端
import { DeleteCustomer } from '@deliverart/sdk-js-customer';
await sdk.call(new DeleteCustomer('customer-123'));
客户地址
创建客户端地址
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
}
}));
输入参数:
customer: string(需要) - 客户IRIstreet: string(需要) - 街道地址city: string(必须) - 城市postalCode: string(需要) - 邮政编码country: string(需要) - 国家代码(ISO 3166-1 α-2)state?: string(可选)-国家/地区province?: string(可选) - 省location?: { latitude: number, longitude: number }(可选) - GPS 坐标
获取客户界面
import { GetCustomerAddresses } from '@deliverart/sdk-js-customer';
const addresses = await sdk.call(new GetCustomerAddresses({
query: {
customer: '/customers/123'
}
}));
更新客户端地址
import { UpdateCustomerAddress } from '@deliverart/sdk-js-customer';
const updated = await sdk.call(new UpdateCustomerAddress('address-123', {
street: 'Via Nuova 10'
}));
删除客户端
import { DeleteCustomerAddress } from '@deliverart/sdk-js-customer';
await sdk.call(new DeleteCustomerAddress('address-123'));
业务概况(B2B)
创建客户端
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]'
}
}));
输入参数:
customer: string(需要) - 客户IRIbusinessName: string(需要) - 企业名称vat: string(需要) - 增值税号码taxCode?: string(可选) - 税法billingAddress: Address(需要) - 账单地址billingData: BillingData(要求) - 收费联系信息
获取客户端
import { GetCustomerBusinessProfiles } from '@deliverart/sdk-js-customer';
const profiles = await sdk.call(new GetCustomerBusinessProfiles({
query: {
customer: '/customers/123'
}
}));
更新客户端商业文件
import { UpdateCustomerBusinessProfile } from '@deliverart/sdk-js-customer';
const updated = await sdk.call(new UpdateCustomerBusinessProfile('profile-123', {
businessName: 'Acme Corporation'
}));
删除客户端
import { DeleteCustomerBusinessProfile } from '@deliverart/sdk-js-customer';
await sdk.call(new DeleteCustomerBusinessProfile('profile-123'));
完成使用示例
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`);
}
许可证
麻省理工学院