Customer Model
Properties
The unique identifier of the customer
Name of the customer. If your app has lastName, this should be set to firstName value.
Set this if your app has lastName and firstName, otherwise use name.
Specify at least email or phone (or both). Email enables dunning and reactivation email campaigns, email verification codes, and email-based audience segmentation. Without both email and phone, dunning and reactivation campaigns will not send any messages.
Specify at least email or phone (or both). Phone enables SMS dunning campaigns and SMS verification codes. Without both email and phone, dunning and reactivation campaigns will not send any messages.
Array of customer's billing addresses. First address is considered primary
Array of discounts applied to the customer. If your app has customer level discounts, you can specify them in the discounts array. Make sure you already have a Coupon model to use it here.
If your app associates a currency with a customer, set this field to an ISO currency code ISO 4217.
Arbitrary data in key-value format. Where both key and value are strings.
Code Example
import { Integrator } from '@churnkey/sdk'
export class Customer extends Integrator.Customer {
constructor(customer: YourCustomer) {
super({
id: customer.id,
... // map other properties
})
}
}
import { Coupon } from './Coupon'
interface Customer {
id: string
name?: string
lastName?: string
email?: string
phone?: string
addresses?: Address[]
discounts?: Discount[]
currency?: string
metadata?: Record<string, string>
}
interface Address {
country?: string
state?: string
city?: string
postalCode?: string
line1?: string
line2?: string
}
interface Discount {
coupon: Coupon
start?: Date
end?: Date
}
export function Customer(customer: YourCustomer): Customer {
return {
id: customer.id,
... // map other properties
}
}
package models
import (
"time"
)
type Customer struct {
ID string `json:"id"`
Name *string `json:"name"`
LastName *string `json:"lastName"`
Email *string `json:"email"`
Phone *string `json:"phone"`
Addresses []Address `json:"addresses"`
Discounts []Discount `json:"discounts"`
Currency *string `json:"currency"`
Metadata map[string]string `json:"metadata"`
}
type Address struct {
Country *string `json:"country"`
State *string `json:"state"`
City *string `json:"city"`
PostalCode *string `json:"postalCode"`
Line1 *string `json:"line1"`
Line2 *string `json:"line2"`
}
type Discount struct {
Coupon Coupon `json:"coupon"`
Start *time.Time `json:"start"`
End *time.Time `json:"end"`
}
func Customer(customer YourCustomer) Customer {
return Customer{
ID: customer.ID,
// map other properties
}
}